国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

詳解TypeScript+Vue 插件 vue-class-component的使用總結(jié)

2019-11-19 12:07:27
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

首先 下載

npm install vue-class-component vue-property-decorator --save-dev

一梭子直接干;

其次,咱來(lái)說(shuō)說(shuō)它們的區(qū)別與聯(lián)系:

vue-property-decorator社區(qū)出品;vue-class-component官方出品

vue-class-component提供了Vue、Component等;

vue-property-decorator深度依賴了vue-class-component,拓展出了更多操作符:@Prop、@Emit、@Inject、@Model、@Provide、@Watch;

開發(fā)時(shí)正常引入vue-property-decorator就行

引入后寫vue代碼就是如此,

import {Component, Prop, Vue} from 'vue-property-decorator'@Componentexport 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(); }}

相當(dāng)于

export default { data () { return {  name: 'Simon Zhang' } }, mounted () { this.sayHello() }, computed: { MyName() {  return `My name is ${this.name}` } }, methods: { sayHello() {  alert(`Hello ${this.name}`) }, }}

大佬都說(shuō)爽的一批;

然鵝菜鳥我遇到問(wèn)題一堆,以下做個(gè)積累總結(jié):

1、寫法問(wèn)題:引入組件和接收父組件傳過(guò)來(lái)的參數(shù)

@Component({ components: { XXXX }, props: { mapFlag: Number }})

2、獲取refs,在其后面加上as HTMLDivElement(不知道是不是這插件引起的,懶得管,直接干就是)

let layoutList:any = this.$refs.layout as HTMLDivElement

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 买车| 昭苏县| 泸西县| 铁岭县| 迭部县| 平和县| 两当县| 大新县| 丹棱县| 临漳县| 福州市| 招远市| 安阳县| 镇雄县| 江孜县| 兴化市| 垣曲县| 德令哈市| 浙江省| 友谊县| 达孜县| 土默特右旗| 合山市| 永仁县| 昌邑市| 磐安县| 休宁县| 嘉定区| 韶山市| 禹州市| 宁城县| 桃园市| 衢州市| 钦州市| 嘉黎县| 三台县| 秦皇岛市| 连州市| 科尔| 上虞市| 温州市|