uniapp: add address port before rich text picture/video/audio path

dealTxt(htmlStr) { 
    console.log('htmlStr', htmlStr) // 从接口获取到富文本内容
	let apiSource = 'http://00.000.00.198:8080/';  // 地址端口
	const _imgL = '<img src="';
	const _video = '<video src="'
	const _href = '<a href="'
	if (htmlStr) {
		if (htmlStr.includes(_imgL)) {
			htmlStr = htmlStr.replace(/<img src=\"/g, '<img class="123" src="' + apiSource)
		}
	    if (htmlStr.includes(_video)) {
			htmlStr = htmlStr.replace(/<source src=\"/g, '<source src="' + apiSource)
		}
		if (htmlStr.includes(_href)) {
			htmlStr = htmlStr.replace(/<a href=\"/g, '<a href="' + apiSource)
		}
	}
	console.log('htmlStr', htmlStr)
	return htmlStr;
},
this.huiy = this.dealTxt(this.info.contentInfo) // 富文本字段

Guess you like

Origin blog.csdn.net/Ygaidi/article/details/128670772