怎么删除掉数组里的 detail里面的六四个\和P标签
,包括删除<>// 模拟数据
var list = [
{detail: "<p><img src=\"https://dededew.jpg\" alt=\"\" /><p>", text: '21'}
]
// 定义函数
function getImgStr (str) {
if (!(str && str.includes('<img'))) return str
return str.replace(/.*(<img.*\/>).*/, '$1').replace(/\"/g, "'")
}
list.forEach(i => {
i.detail = getImgStr(i.detail)
})
console.log(list)
输出结果值
用replice函数替换为空
detail.replice(//g,"")
遍历,替换即可