rich-text無法渲染,我們可以去插件市場 找uParse 富文本解析插件進行替換
uParse 地址:uParse插件鏈接
或者獲取video的鏈接
function getVideo(data) {
let videoList = [];
let videoReg = /<video.*?(?:>|\/>)/gi; //匹配到字符串中的 video 標簽
let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i; //匹配到字符串中的 video 標簽 的路徑
let arr = data.match(videoReg) || []; // arr 為包含所有video標簽的數組
let articleList = data.split('</video>') // 把字符串 從視頻標簽分成數組
arr.forEach((item, index) => {
var src = item.match(srcReg);
videoList.push(src[1]) //所要顯示的字符串中 所有的video 標簽 的路徑
})
let needArticleList = [];
articleList.forEach((item, index) => {
if (item != "" && item != undefined) { // 常見的標簽渲染
needArticleList.push({
type: 'rich-text',
value: item + "</video>"
});
}
let articleListLength = articleList.length; // 插入到原有video 標簽位置
if (index < articleListLength && videoList[index] != undefined) {
needArticleList.push({
type: 'video',
value: videoList[index]
})
}
})
return needArticleList
}