vue里面的v-for循环使用
<el-table :data="tableData" style="width: 100%">
<tr v-for="col in cols">
<el-table-column v-if="col.type==='normal'" :prop="col.prop"
:label="col.label"></el-table-column>
<el-table-column v-if="col.type==='sort'" :prop="col.prop" sortable :label="col.label">
<template scope="scope">
<el-tag type="primary">{{ scope.row.type }}</el-tag>
</template>
</el-table-column>
</tr>
</el-table>
cols: [{label: '节点编号', prop: 'node', type: 'normal'}, {label: '名称', prop: 'name', type: 'normal'}, {label: '类型', prop: 'type', type: 'sort'},
{label: '坐标', prop: 'coordinate', type: 'normal'}]
tableData:[{
node: '0051',
name: ' 机库顶',
type: 'UWB',
status: '正常',
coordinate: '12.21,34.45,34.6'
}, {
node: '0061',
name: '机库门',
type: 'GPS',
status: '低电',
coordinate: '45.41,67.45,78.6'
}]
节点编号这一列跑到了最后一列
查了一下循环流动的问题,没找到合适的方法
v-for出最好用template进行封装,这个问题我们也出现,按照上面的格式就可以解决