详解TypeScript+Vue 插件 vue-class-component的使用总结
网络编程 2021-07-04 15:50www.168986.cn编程入门
这篇文章主要介绍了TypeScript+Vue 插件 vue-class-ponent的使用总结,长沙网络推广觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随长沙网络推广过来看看吧
首先 下载
npm install vue-class-ponent vue-property-decorator --save-dev
一梭子直接干;
其次,咱来说说它们的区别与联系:
vue-property-decorator社区出品;vue-class-ponent官方出品
vue-class-ponent提供了Vue、Component等;
vue-property-decorator深度依赖了vue-class-ponent,拓展出了更多操作符:@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' // puted 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() }, puted: { MyName() { return `My name is ${this.name}` } }, methods: { sayHello() { alert(`Hello ${this.name}`) }, } }
大佬都说爽的一批;
然鹅菜鸟我遇到问题一堆,以下做个积累总结:
1、写法问题:引入组件和接收父组件传过来的参数
@Component({ ponents: { XXXX }, props: { mapFlag: Number } })
2、获取refs,在其后面加上as HTMLDivElement(不知道是不是这插件引起的,懒得管,直接干就是)
let layoutList:any = this.$refs.layout as HTMLDivElement
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持狼蚁SEO。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程