uniapp富文本的使用

<editor class="richInputContent" id="editor" @input="getEditorContent" @ready="onEditorReady" v-model="html"></editor>
methods:{
      //初始化富文本编辑器
onEditorReady() {
uni.createSelectorQuery().select('#editor').context((res) => {
var contentVal_1 = this.content;
//将内容写入编辑器
this.editorCtx = res.context;
let EContent = {
html: contentVal_1
}
this.editorCtx.setContents(EContent);
}).exec()
},
getEditorContent(e) {
this.content = e.detail.html;
this.contentText = e.detail.text;
},
//上传图片
uploadImg(index) {
let that = this
uni.chooseImage({
count: 1,
success: function(res) {
let url = res.tempFilePaths[0]
console.log(res)
uni.uploadFile({
url: 'https://nmssafety.51yunmai.com/FileUpload/FileUploadMobile',
filePath: url,
name: 'Data',
formData: {
token: uni.getStorageSync("token")
},
success: (res) => {
console.log(res)
that.editorCtx.insertImage({
src: JSON.parse(res.data).ImageUrl,
alt: '图像',
success: function() {}
})
}
});
},
})
},
}

editorContext.format(name, value)  修改富文本样式

更多查看该链接https://uniapp.dcloud.io/api/media/editor-context?id=editorcontextformat

posted @   蓦然JL  阅读(1735)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
  1. 1 唯一 G.E.M.邓紫棋
  2. 2 他只是经过 白敬亭 魏大勋
  3. 3 Uptown Funk Mark Ronson / Bruno Mars
  4. 4 在你的身边 盛哲
  5. 5 Edge of My Life Manafest
  6. 6 凄美地 郭顶
  7. 7 Wonderful Tonight Boyce Avenue
  8. 8 心如止水 Ice Paper
  9. 9 Sugar Maroon 5
  10. 10 静谧时光 JIAxNING
  11. 11 Right Now (Na Na Na) Aamir
  12. 12 Dangerously Charlie Puth
  13. 13 Someone You Loved Madilyn Paige
  14. 14 Shape of My Heart Boyce Avenue
  15. 15 We Can't Stop Boyce Avenue / Bea Miller
  16. 16 Perfect Boyce Avenue
  17. 17 Love Me Like You Do Boyce Avenue
  18. 18 Thank You Boyce Avenue
  19. 19 Don’t Wanna Know Boyce Avenue / Sarah Hyland
他只是经过 - 白敬亭 魏大勋
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

Not available

访问主页
关注我
关注微博
私信我
返回顶部
点击右上角即可分享
微信分享提示

目录导航