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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM