没有合适的资源?快使用搜索试试~ 我知道了~
首页详解TypeScript+Vue 插件 vue-class-component的使用总结
详解TypeScript+Vue 插件 vue-class-component的使用总结
1.2k 浏览量
更新于2023-05-26
评论
收藏 42KB PDF 举报
主要介绍了TypeScript+Vue 插件 vue-class-component的使用总结,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
资源详情
资源评论
资源推荐

详解详解TypeScript+Vue 插件插件 vue-class-component的使用总结的使用总结
主要介绍了TypeScript+Vue 插件 vue-class-component的使用总结,小编觉得挺不错的,现在分享给大家,也
给大家做个参考。一起跟随小编过来看看吧
首先 下载
npm install vue-class-component vue-property-decorator --save-dev
一梭子直接干;
其次,咱来说说它们的区别与联系:
vue-property-decorator社区出品;vue-class-component官方出品
vue-class-component提供了Vue、Component等;
vue-property-decorator深度依赖了vue-class-component,拓展出了更多操作符:@Prop、@Emit、@Inject、@Model、
@Provide、@Watch;
开发时正常引入开发时正常引入vue-property-decorator就行就行
引入后写vue代码就是如此,
import {Component, Prop, Vue} from 'vue-property-decorator'
@Component
export default class App extends Vue {
name:string = 'Simon Zhang'
// computed
get MyName():string {
return `My name is ${this.name}`
}
// methods
sayHello():void {
alert(`Hello ${this.name}`)
}
mounted() {
this.sayHello();
}
}
相当于
export default {
data () {
return {
name: 'Simon Zhang'
}
},
mounted () {
this.sayHello()
},
computed: {
MyName() {
return `My name is ${this.name}`
}
},
methods: {
sayHello() {
alert(`Hello ${this.name}`)
},
}
}
大佬都说爽的一批;
然鹅菜鸟我遇到问题一堆,以下做个积累总结:
















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0