js 富文本批量替换

js yekong

将富文本字符串中的相对地址图片替换为绝对地址图片

that.data.content = that.data.content.replace(/\/ueditor/g, configs.baseUrl + '\/ueditor')

替换前:

"content": "<p><img src=\"/ueditor/php/upload/image/20220209/1644383745996882.png\" title=\"1644383745996882.png\"/></p><p><img src=\"/ueditor/php/upload/image/20220209/1644383745395624.png\" title=\"1644383745395624.png\"/></p><p><img src=\"/ueditor/php/upload/image/20220209/1644383745142922.png\" title=\"1644383745142922.png\"/></p><p><img src=\"/ueditor/php/upload/image/20220209/1644383745641617.png\" title=\"1644383745641617.png\"/></p><p><img src=\"/ueditor/php/upload/image/20220209/1644383745529567.png\" title=\"1644383745529567.png\"/></p><p><img src=\"/ueditor/php/upload/image/20220209/1644383745909735.png\" title=\"1644383745909735.png\"/></p><p><br/></p>",
	

替换后

<p><img src="https://www.wanjunshijie.com/ueditor/php/upload/image/20220209/1644383745996882.png" title="1644383745996882.png"/></p><p><img src="https://www.wanjunshijie.com/ueditor/php/upload/image/20220209/1644383745395624.png" title="1644383745395624.png"/></p><p><img src="https://www.wanjunshijie.com/ueditor/php/upload/image/20220209/1644383745142922.png" title="1644383745142922.png"/></p><p><img src="https://www.wanjunshijie.com/ueditor/php/upload/image/20220209/1644383745641617.png" title="1644383745641617.png"/></p><p><img src="https://www.wanjunshijie.com/ueditor/php/upload/image/20220209/1644383745529567.png" title="1644383745529567.png"/></p><p><img src="https://www.wanjunshijie.com/ueditor/php/upload/image/20220209/1644383745909735.png" title="1644383745909735.png"/></p><p><br/></p>
喜欢