uniapp解析富文本视频


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
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM