今天刚写完页面 点击详情按钮时,对话框弹不出来,F12查看Console 就已经报错了。
报错内容如下:
Property or method "View" 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
属性或方法“rowView”未在实例上定义,但在渲染过程中被引用。通过初始化属性,确保该属性在数据选项中或在基于类的组件中是反应性的
![](https://i-blog.csdnimg.cn/blog_migrate/f886af192a904f2c203c6bb9b2a8ff4d.png)
解决方法:
我的原因是将View()方法写在了methods的外面😭,还找了蛮久的......
将View()方法放到methods中就行了
methods: {
//详情
rowView(row) {
// 显示窗口
this.name = "详情"
this.dialogVisibleView = true
API.query(row.id).then(res => {
if (res.data.code == 0) {
this.form = res.data.data
}
})
this.dialogVisibleView = true;
},
}
Property or method "详情" is not defined on the instance but referenced during render
Error in event handler for "click": "TypeError: _vm.rowView is not a function"
属性或方法“详情“未在实例上定义,但在渲染过程中引用。
“click”的事件处理程序出错:“TypeError:_vm.rowView不是函数”
![](https://i-blog.csdnimg.cn/blog_migrate/e1ba00ed583fd309711d26d2c577b5a3.png)
解决方法:
详情用双引号(正确示范)
<el-dialog name="详情" :visible.sync="dialogVisibleView" width="50%">
<div>
<el-form ref="form" :model="form" label-width="120px">
<el-form-item label="学生名称">
<el-input v-model="form.name" :disabled="true"></el-input>
</el-form-item>
<el-form-item label="学生性别">
<el-radio-group v-model="form.sex" >
<el-radio :label="1">男</el-radio>
<el-radio :label="2">女</el-radio>
</el-radio-group>
</el-form-item>
</div>
</el-dialog>
未改之前,我将name="详情" 写成了:name="详情"(error);返回的data(){}中我写的是name:'详情'
正确的写法:是将单引号改为双引号