Javascript 如何在Nuxt.js应用程序中使用具有Nuxt属性decortor的mixin
我在最新的项目中使用了Nuxt.js,语言是TypeScript。 另外,我使用的是Javascript 如何在Nuxt.js应用程序中使用具有Nuxt属性decortor的mixin,javascript,typescript,vue.js,nuxt.js,mixins,Javascript,Typescript,Vue.js,Nuxt.js,Mixins,我在最新的项目中使用了Nuxt.js,语言是TypeScript。 另外,我使用的是numxt属性装饰器。 我试图理解下面代码中的“mixins”属性 mixins.vue↓ <template> <div> <p>{{hello}}</p> </div> </template> <script lang="ts"> import { Component ,Vu
numxt属性装饰器
。
我试图理解下面代码中的“mixins”属性
mixins.vue↓
<template>
<div>
<p>{{hello}}</p>
</div>
</template>
<script lang="ts">
import { Component ,Vue } from 'nuxt-property-decorator'
import Mixin from "~/mixins/mixin";
@Component({
mixins:[
Mixin
]
})
export default class extends Vue{
greeting:string = 'Hello'
}
</script>
我希望输出中出现“Hello worlds!”
,但出现了一个错误:
Property or method "hello" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
有人能告诉我吗?混音器必须用
@组件装饰:
//mixin.ts
从“nuxt属性装饰器”导入{Component,Vue};
@组件混音器必须用@Component
装饰:
//mixin.ts
从“nuxt属性装饰器”导入{Component,Vue};
@组成部分
Property or method "hello" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.