【发布时间】:2018-12-02 11:11:27
【问题描述】:
我正在使用 Vue.extend 创建一个带有 Array prop 的 AppProps 类...
import Vue from 'vue';
import Component from 'vue-class-component';
const AppProps = Vue.extend({
props: {
test1: String,
test2: Array,
},
});
然后扩展 AppProps 来创建我的组件..
@Component({})
export default class ArrayPropsExample extends AppProps {
get computedMessage() {
return this.test1 + ' ' + this.test2;
}
}
这是根据 vue-class-component 中的打字稿示例。 Vue 很高兴,但 linter 抱怨它在课堂上看不到我的道具类型......
19:17 类型“ArrayPropsExample”上不存在属性“test1”。 17 |导出默认类 ArrayPropsExample 扩展 AppProps { 18 |获取计算消息() {
19 |返回 this.test1 + ' ' + this.test2; | ^ 20 | } 21 | }
相关代码在这里(https://github.com/JavascriptMick/vue-d3-poc/blob/master/src/components/ArrayPropsExample.vue)
如果我将 test2 类型设置为 String,linter 很高兴,但使用 Array 似乎会破坏 linter.. 这很奇怪且不一致
【问题讨论】:
标签: typescript vue.js tslint