报错:Property or method “remarkFlag” 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
一般遇到这个报错,是说属性或方法未定义,就已经开始使用了
排查一下
模板区定义了方法,方法中是否对应写了方法名
模板区使用的属性,是否在data中定义了属性
我今天遇到的稍稍不一样,所以记录一下
在模板区的table插槽中,因为封装成组件之后,获取值要scope.row这样点出来
<el-table-column align="center" label="xx说明">
<template slot-scope="scope">
<el-input
v-if="remarkFlag"
v-model="scope.row.remark"
autosize
placeholder="请输入xx说明"
type="textarea"
/>
<span v-else >{{ scope.row.remark }}</span>
</template>
</el-table-column>
报错的原因就是 v-if=“remarkFlag” 不能直接这样写,这个值是在父组件中获取到的,通过组件传值传给列表,所以要这样写才行 v-if=“scope.row.remarkFlag”
<el-table-column align="center" label="xx说明">
<template slot-scope="scope">
<el-input
v-if="scope.row.remarkFlag"
v-model="scope.row.remark"
autosize
placeholder="请输入xx说明"
type="textarea"
/>
<span v-else >{{ scope.row.remark }}</span>
</template>
</el-table-column>