//处理地址 let processedStr = str.replace(/位于([^。;,,]+?)(?=[。;,,]|$)/g,(match, address) => {return `位于<a href="#" data-type="address" data-address="${address}" style="color: #0088cc; text-decoration: underline;">${address}</a>`;});// 处理电话号码processedStr = processedStr.replace(phoneReg, (match) => {// 保持原始显示格式,但去除横线用于拨号 这里用a标签代替拨打手机号const purePhone = match.replace(/-/g, '');return `<a href="#" data-type="phone" data-phone="${purePhone}" style="color: #0088cc; text-decoration: underline;">${match}</a>`;});return processedStr;
<mp-html content="{{item.answer}}"bindlinktap="linktap"selectable="true"bindimgtap="imgtap" />
<!-- bindlinktap可监听到a标签的点击事件 -->
<!-- bindimgtap可监听到图片预览事件 -->