1:查询字符串是否包含某个字符
item.includes(’,’) //是否包含’ , ’
2: 字符串转换数组
item.split(’,’) //字符串以’ , ’ 的到数组
3:多维数组降为一维数组
例: nameArr = [2,[3,4],6,[8,9]]
nameArr.flat(Infinity)
console.log(nameArr) //[2,3,4,6,8,9]
//表格默认选中
表格上加
<el-table
ref="multipleTable"
:data="gridData"
stripe
style="width: 100%"
height="300px"
@toggleRowSelection="hasSelectList"
@selection-change="handleSelectionChange"
><el-table>
data(){
return{
hasSelectList:[]
}
}
method:{
// 这里给的一个条件,按照这个条件展示选中
this.$nextTick(() => {
this.gridData.forEach((row, i) => {
this.tableData.forEach((item, j) => {
if (this.gridData[i].room_no === this.tableData[j]) {
this.$refs.multipleTable.toggleRowSelection(row, true)
}
})
})
})
}