小程序開放了原生的富文本編輯組件editor,功能還是挺豐富的,有興趣的大家可以看下
官方文檔:https://developers.weixin.qq.com/miniprogram/dev/component/editor.html
相關api:https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.html
editor組件
使用方法的話很簡單,直接復制文檔中的示例修改下就能用了
這里提供一個方法,可以初始化editro組件的內容
const query = wx.createSelectorQuery()
? ? ? ? query
? ? ? ? ? .select('#editorId')
? ? ? ? ? .context(function (res) {
? ? ? ? ? ? res.context.setContents({
? ? ? ? ? ? ? html: '相關內容'
? ? ? ? ? ? })
? ? ? ? ? })
? ? ? ? ? .exec()