- Vue+IView使用table组件在项目中遇到的问题记录
- Vue使用element-ui中的popover点击取消按钮隐藏
- element table 与popover踩坑记录
- 记录一个小点react+antd:支持css3的transiti
- Vscode vue+iview,Eslint总是报错‘[vue
- element中的el-table在IE浏览器中的宽度显示异常问
- 【antd】Table组件勾选功能:分页后拼接勾选的行数组
- Element UI表格在切换tab时或者在切换页面时table
- el-image设置lazy之后滚动不会进行加载
- iview中的render函数由于从别的组件中引入,所以this
Vue项目开发中问题随笔:
业务逻辑是这样的,在iView的table组件数据列表每行添加单选按钮后要绑定ref操作,ref的名字是radio加入id,获取ref时发现的小问题。
下面贴出解决方法,记录一下
通过ivew的文档提供的方法,给Table 绑定点击行触发事件@on-row-click="rowClick"。
<Table ref="tableTitle" @on-row-click="rowClick" :columns="hotField" :data="hotProItem">
<template slot-scope="{ row, index }" slot="select">
<div :ref="`radio${row.id}`" ></div>
</template>
</Table>
最开始测试了下,能打印出来想要的ref名字,打印this.$refs也可以看见想要的名字
rowClick(rowItem){
const radioItem = `radio${ rowItem .id}`
console.log(radioItem);
console.log(this.$refs);
},
打印如下:
所以就天真的写上了console.log(this.$refs.radioItem),结果输出了undefined。
解决方法:
rowClick(rowItem){
console.log( this.$refs[`radio${rowItem.id}`] );
},
可以正常拿到了点击某行的那个ref了。
网友评论