【发布时间】:2019-01-26 03:37:30
【问题描述】:
当我使用 TypeScript 时,我试图在渲染中使用它。 但它无法运行:
TS2339:类型上不存在属性“选项” '组件选项,默认方法, DefaultComputed, PropsDefinition
import Vue from 'vue'
declare module 'vue/types/vue' {
interface Vue {
onSwtich: Function
}
}
export default Vue.extend({
name: 'footerTabs',
data() {
return {
options: {
on: {
click: el => this.onSwtich(el)
}
}
}
},
render(h) {
return h('swiper', {
class: 'page-footer-tabs',
attrs: {
options: this.options // TS2339: Property 'options' does not exist on type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Rec...'.
}
})
},
methods: {
onSwtich(el): void {
this.$emit('on-switch', el)
}
}
})
我已经尝试添加选项
界面 Vue { 选项:对象 }
还是不行
【问题讨论】:
标签: typescript vue.js