Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Nuxt.js应用程序中使用具有Nuxt属性decortor的mixin_Javascript_Typescript_Vue.js_Nuxt.js_Mixins - Fatal编程技术网

Javascript 如何在Nuxt.js应用程序中使用具有Nuxt属性decortor的mixin

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

我在最新的项目中使用了Nuxt.js,语言是TypeScript。 另外,我使用的是
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.