- 报错:
vue.js:634 [Vue warn]: Property or method "w" 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.
关键代码:
<div id="vm7">
<child :content="w"></child>
<child content='k'></child>
</div>
<script>
Vue.component('child',{
props:['content'],
template:'<div @click="handleClick">{
{content}}</div>'
});
</script>
问题解释:
组件使用:content
的那行报错 ,而content
那行没有报错。
加:content
等号后面相当于是js表达式,而content
等号后面是字符串的内容。
解决方法:
方法一:将:content
换为第二行的写法content