editor组件插入图片,html img中没有data-local字段,真机调试正常,是什么问题?
发布于 6 年前 作者 houjie 14436 次浏览 来自 问答

将editor组件封装到自定义组件后,使用以下代码插入图片:

const that = this
wx.chooseImage({
  count1,
  successfunction (res{
    that.data.editorCtx.insertImage({
      src: res.tempFilePaths[0]
    })
  }
})

获取input事件返回的detail.html 中 <img>标签中不含 data-local字段。但真机调试时,该字段正常。 请问在真机上用 data-local字段 是否可靠?

开发工具版本 stable 1.03.2012120

调试基础库2.7.0

3 回复

从测试和分析情况看,估计小程序editor组件是依靠 本地临时文件的fake链接开头协议字符串,判断是否本地文件,如果是,则增加data-local字段。 开发工具调试时,本地临时文件是http开头,所以没有data-local,手机上时wxfile开头则正常。

另外 富文本插图API EditorContext.insertImage(Object object) 中的 width和height属性在调试工具上也不生效,手机上正常。

可不可靠 你用真机调试打印下试试呗

请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

回到顶部