Closed metanoia1989 closed 5 years ago
页面js文件
Page({ data: { html: '', uploadUrl: '', key: '' }, onLoad: function (options) { let uploadUrl = Api.getImageUpload(); this.setData({ uploadUrl: uploadUrl, html: wx.getStorageSync(options.key), key: options.key }); console.log(this.data.html) },
wxml文件
<xing-editor bindfinish="finish" output-type="html" image-upload-url="{{uploadUrl}}" image-upload-name="article" image-upload-key-chain="result.url" html="{{html}}"/>
打印出来的this.data.html是有值的,但是页面没有展示html内容。 需要修改组件的js文件,把attached() 中的部分代码放到 ready() 中 xing-editor.js
this.data.html
ready: function() { if (this.properties.nodes && this.properties.nodes.length > 0) { const textBufferPool = []; this.properties.nodes.forEach((node, index) => { if (node.name === 'p') { textBufferPool[index] = node.children[0].text; } }) this.setData({ textBufferPool, nodeList: this.properties.nodes, }) } else if (this.properties.html) { const nodeList = this.HTMLtoNodeList(); const textBufferPool = []; nodeList.forEach((node, index) => { if (node.name === 'p') { textBufferPool[index] = node.children[0].text; } }) this.setData({ textBufferPool, nodeList, }) } },
微信文档上关于 attached() 和 ready() 的解释:
attached()
ready()
attached 组件生命周期函数,在组件实例进入页面节点树时执行 | ready 组件生命周期函数,在组件布局完成后执行,此时可以获取节点信息(使用 SelectorQuery )
菜鸟不是很懂啦。
fixed
页面js文件
wxml文件
打印出来的
this.data.html
是有值的,但是页面没有展示html内容。 需要修改组件的js文件,把attached() 中的部分代码放到 ready() 中 xing-editor.js微信文档上关于
attached()
和ready()
的解释:菜鸟不是很懂啦。