Vue-class-component(一)

 Vue-class-component  vue 的官方库,作用是使用类样式语法编写vue组件。

<template> 
<button v—on: 
{{ count 
<button v—on: click=" increment">+</button> 
ript> 
export default { 
data ( ) { 
return { 
count: 0 
created ( ) { 
this. count = 10 
computed: { 
classMessage ( ) { 
return ' if"Wä-: ' 
methods: { 
increment ( ) { 
this. count++ 
decrement ( ) { 
this. count-— 
</script> 
+ this. count

<button v—on:click="decrement">—</button> 
{{ count 
<button 
</template> 
import Vue from 'vue' 
im ort Com onent from 
@Component 
export defaul class 
count 
created 
this.count = 
'vue-class.com onent• 
extends Vue 
get class-Message O { 
return + this. coun 
set classMessage (vat) { 
console. log (vat, ) 
increment ( ) { 
this. count++ 
decrement ( ) { 
this count—— 
</script>

data render 和所有Vue生命周期挂钩也可以直接声明为类成员方法,但不能在实例本身上调用它们。在声明自定义方法时,应避免使用这些保留名称。

 

vue-property-decorator  

完全依赖于vue-class-component,提供了装饰器方法:

@Component(options)--- (完全继承于vue-class-component)

1,component

2,filters

 3directives

 @Prop

@Watch

@Emit

@Model

@Inject

@Provide

 

posted @ 2020-08-31 10:29  85号bobo  阅读(4823)  评论(0)    收藏  举报