页面显示的效果图如上,
1. 页面结构
assets文件夹在官方给的示例里面有,参照 editor | 微信开放文档
2. other.js
在页面 Page 函数中,创建 onEditorReady 函数,用来获取富文本编辑器示例EditorContext
onEditorReady() {
const that = this;
wx.createSelectorQuery().select('#editor').context(function (res) {
that.editorCtx = res.context
}).exec()
},
/**
* 页面的初始数据
*/
data: {
//编辑器设置
editorHeight: 300,
readOnly: false,
placeholder: '开始输入...'
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let neirong = '<ul data-checked="true"><li>asd</li><li>zxc</li><li>qwe</li></ul>';
wx.createSelectorQuery().select('#editor').context(function (res) {
this.editorCtx = res.context;
//初始化编辑器---&