2720关注8916浏览
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 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
})
}
})
}
})
}
})
-
至过去的我
2044人对此回答表示赞同
我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多> -
回忆的沙漏
17人对此回答表示赞同
代码:wechatide://minicode/kBCXYomQ7w1h
展开171回复分享发布于 6年前评论(1)
收起评论
反馈已收到,感谢反馈