1.利用split切数组
2.先切成规律数组,在利用正则的match获取到符合条件的字符串
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="=width=device-=width, initial-scale=1.0">
<title>Document</title>
</head>
<div id="strId">
fixed
label="采集时间"
align="center"
prop="caiJiShiJian"
width="170"
/>
dci-table-column label="接入时间" align="center" prop="createTime" width="170" />
dci-table-column label="编号" align="center" prop="guoLuBianHao" width="120" />
dci-table-column label="名称" align="center" prop="guoLuMingCheng" width="150" />
dci-table-column
label="出水温度℃"
align="center"
prop="guoLuChuShuiWenDu"
width="110"
suffix=""
/>
dci-table-column
label="预热器右出口风温℃"
align="center"
prop="yuReQiYouChuKouFengWen"
width="180"
suffix=""
/>
dci-table-column
label="预热器左出口烟温℃"
align="center"
prop="yuReQiZuoChuKouYanWen"
width="180"
suffix=""
/>
dci-table-column
label="预热器右出口烟温℃"
align="center"
prop="yuReQiYouChuKouYanWen"
width="180"
suffix=""
/>
dci-table-column
label="省煤器左出口烟温℃"
align="center"
prop="shengMeiQiZuoChuKouYanWen"
width="180"
suffix=""
/>
dci-table-column
label="省煤器右出口烟温℃"
align="center"
prop="shengMeiQiYouChuKouYanWen"
width="180"
suffix=""
/>
dci-table-column
label="除尘器入口烟温℃"
align="center"
prop="chuChenQiRuKouYanWen"
width="180"
suffix=""
/>
dci-table-column
label="除尘器出口烟温℃"
align="center"
prop="chuChenQiChuKouYanWen"
width="180"
suffix=""
/>
dci-table-column
label="引风机出口烟温℃"
align="center"
prop="yinFengJiChuKouYanWen"
width="180"
suffix=""
/>
dci-table-column
label="鼓风机出口风温℃"
align="center"
prop="guFengJiChuKouFengWen"
width="180"
suffix=""
/>
dci-table-column
label="出水压力MPa"
align="center"
prop="guoLuChuShuiYaLi"
width="180"
suffix=""
/>
dci-table-column
label="回水压力MPa"
align="center"
prop="guoLuHuiShuiYaLi"
width="180"
suffix=""
/>
dci-table-column
label="炉膛压力Pa"
align="center"
prop="guoLuLuTangYaLi"
width="180"
suffix=""
/>
dci-table-column
label="鼓风机出口压力Pa"
align="center"
prop="guFengJiChuKouYaLi"
width="180"
suffix=""
/>
dci-table-column
label="烟气含氧量%"
align="center"
prop="guoLuYanQiHanYangLiang"
width="180"
suffix=""
/>
dci-table-column
label="引风机频率Hz"
align="center"
prop="yinFengJiPinLv"
width="180"
suffix=""
/>
dci-table-column
label="鼓风机频率Hz"
align="center"
prop="guFengJiPinLv"
width="180"
suffix=""
/>
dci-table-column
label="炉排机频率Hz"
align="center"
prop="luPaiJiPinLv"
width="180"
suffix=""
/>
dci-table-column
label="给煤机频率Hz"
align="center"
prop="geiMeiJiPinLv"
width="180"
suffix=""
/>
dci-table-column
label="引风机电流A"
align="center"
prop="yinFengJiDianLiu"
width="180"
suffix=""
/>
dci-table-column
label="鼓风机电流A"
align="center"
prop="guFengJiDianLiu"
width="180"
suffix=""
/>
dci-table-column
label="累计气量m³"
align="center"
prop="guoLuLeiJiQiLiang"
width="150"
suffix=""
/>
dci-table-column
label="在线二氧化硫mg/m³"
align="center"
prop="cemsErYangHuaLiu"
suffix=""
width="180"
/>
dci-table-column
label="在线氮氧化物mg/m³"
align="center"
prop="cemsDanYangHuaWu"
suffix=""
width="180"
/>
dci-table-column
label="在线烟尘mg/m³"
align="center"
prop="cemsYanChen"
suffix=""
width="180"
/>
dci-table-column
label="在线烟气含氧量%"
align="center"
prop="cemsYanQiHanYangLiang"
width="180"
suffix=""
/>
dci-table-column
label="在线烟气温度℃"
align="center"
prop="cemsYanQiWenDu"
width="180"
suffix=""
/>
dci-table-column
label="在线烟气压力Pa"
align="center"
prop="cemsYanQiYaLi"
width="180"
suffix=""
/>
dci-table-column
label="在线烟气流速m/s"
align="center"
prop="cemsYanQiLiuSu"
width="180"
suffix=""
/>
dci-table-column
label="在线烟气湿度%"
align="center"
prop="cemsYanQiShiDu"
width="180"
suffix=""
/>
dci-table-column
label="运行状态"
align="center"
prop="params.guoLuYunXingZhuangTaiName"
width="90"
/>
dci-table-column
label="引风机运行状态"
align="center"
prop="params.yinFengJiYunXingZhuangTaiName"
width="140"
/>
dci-table-column
label="鼓风机运行状态"
align="center"
prop="params.guFengJiYunXingZhuangTaiName"
width="140"
/>
dci-table-column
label="炉排机运行状态"
align="center"
prop="params.luPaiJiYunXingZhuangTaiName"
width="140"
/>
dci-table-column
label="给煤机运行状态"
align="center"
prop="params.geiMeiJiYunXingZhuangTaiName"
width="140"
/>
</div>
<body>
<script>
let dom = document.getElementById("strId").innerText
let str = ""
let objList = []
let labelList = ["label","=prop","=width"]
let arr = dom.split("dci-table-column")
let atr = ''
arr.forEach((item)=>{
let a = item.match(/ prop=\"(\S*)"/)
let prop = a[1]
console.log('SSSS',a[1])
let str = `v-if="columnsProp.${prop} === undefined||columnsProp.${prop} === true"`
let strLong = `<dci-table-column ${str}${item}`
atr = atr + strLong
})
console.log(atr)
// arr.forEach((item)=>{
// let arrValue = item.split('=',)
// arrValue.forEach((text,index)=>{
// // with = text.replace(/\/>/ig,'')
// let width = text.replace(/\/>/ig,'')
// arrValue[index] = width.replace(/\s/ig,'')
// console.log('ddd',arrValue[index])
// })
// console.log(arrValue)
// let obj = {}
// obj[arrValue[0]] = arrValue[1]
// obj[arrValue[2]] = arrValue[3]
// obj[arrValue[4]] = arrValue[5]
// objList.push(obj)
// // console.log('item',item)
// })
console.log(objList)
</script>
</body>
</html>