标签:let 文本 height 上传 function 程序 sel 适配 ase
小程序的富文本编辑框里上传了webp格式的图片,安卓手机可显示,IOS手机不能正常显示,解决办法:
filterTag (str) { if (str) { let mapObj = {} mapObj[‘<img‘] = ‘<img style=\"max-width:100%;height:auto;\"‘ mapObj[‘article>‘] = ‘div>‘ mapObj[‘header>‘] = ‘div>‘ mapObj[‘footer>‘] = ‘div>‘ mapObj[‘section>‘] = ‘div>‘ mapObj[‘/strong>‘] = ‘/span>‘ mapObj[‘<strong‘] = ‘<span class=\"strong\"‘ // 适配webp mapObj[‘&tp=webp‘] = ‘‘ mapObj[‘tp=webp‘] = ‘‘ mapObj[‘&wx_lazy=1‘] = ‘‘ // 富文本可选中 mapObj[‘<div‘] = ‘<div class=\"user-select\"‘ mapObj[‘<p‘] = ‘<p class=\"user-select\"‘ mapObj[‘<span‘] = ‘<span class=\"user-select\"‘ let re = new RegExp(Object.keys(mapObj).join("|"),"gi"); return str.replace(re, function(matched){ return mapObj[matched.toLowerCase()]; }) } else { return ‘‘ } }
后台返回的富文本编辑内容content
调用上面的方法:
filterTag(content)
标签:let 文本 height 上传 function 程序 sel 适配 ase
原文地址:https://www.cnblogs.com/linjiu0505/p/11528598.html