微信小程序的editory用setContents报错

ForkYou 发布于 06/26 16:48
阅读 42
收藏 0

报错信息:

Cannot read property 'setContents' of undefined; [Component] Event Handler Error @ pages/index/index#bound onEditorReady
TypeError: Cannot read property 'setContents' of undefined

 

代码:

<editor placeholder="sdfasdfad"

bindready="onEditorReady"

id="editor"

></editor>

 

Page({

 

/**

* 页面的初始数据

*/

data: {

text:"Hello"

},

onEditorReady() {

const that = this

wx.createSelectorQuery().select('#editor').context(function (res) {

that.editorCtx = res.context

}).exec()

that.editorCtx.setContents({

html: '<html><body><p>Hello<p></body></html>',

success: (res) => {

console.log(res)

},

fail: (res) => {

console.log(res)

}

})

},

加载中
返回顶部
顶部