在IOS设备上rich-text中的图片用本地路径显示不出来
发布于 6 年前 作者 ezheng 17724 次浏览 来自 问答

rich-text 中 <img src=“本地图片路径”/> 图片标签使用本地图片,在IOS中显示不出来

代码如下:

<!–index.wxml–>

<view class=“container”>

<rich-text nodes="{{html}}" bindtap=“tap”></rich-text>

<button bindtap=“selectImg”>选择图片</button>

</view>

//index.js

const app = getApp()

Page({

data: {

html: ‘<div class=“div_class” style=“line-height: 60px; color: red;”>Hello&nbsp;World!</div>’,

},

onLoad: function () {

},

selectImg(){

wx.chooseImage({

count: 1,

sizeType: [‘original’, ‘compressed’],

sourceType: [‘album’, ‘camera’],

success: (res) =>{

let tempFilePaths = res.tempFilePaths

wx.saveFile({

tempFilePath: tempFilePaths[0],

success: (res) => {

let savedFilePath = res.savedFilePath

let html = `<div class=“div_class” style=“line-height: 60px; color: red;”><img src="${savedFilePath}"/></div>`

console.log(html)

this.setData({

html: html

})

}

})

}

})

}

})

1 回复

你好,请提供出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

回到顶部