【发布时间】:2018-07-28 03:11:40
【问题描述】:
我有一个想要基于属性有条件地渲染的组件:
<template>
<div class="logoContainer" v-if="showLogo">
LOGO
</div>
</template>
<script lang="ts">
import Vue from 'vue'
import { Prop } from 'vue-property-decorator'
export default class extends Vue {
@Prop({default: true})
showLogo: boolean
}
</script>
这会产生错误:Property or method "showLogo" 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. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
设置和引用我的showLogo 属性的最简单方法是什么?
【问题讨论】:
标签: typescript vue.js vuejs2 vue-component nuxt.js