1.复制以下代码

<template><view class="container"><view class="page-body"><view class='wrapper'><view class='toolbar' @tap="format" style="height: 120px;overflow-y: auto;"><view :class="formats.bold ? 'ql-active' : ''" class="iconfont icon-zitijiacu" data-name="bold"></view><view :class="formats.italic ? 'ql-active' : ''" class="iconfont icon-zitixieti" data-name="italic"></view><view :class="formats.underline ? 'ql-active' : ''" class="iconfont icon-zitixiahuaxian" data-name="underline"></view><view :class="formats.strike ? 'ql-active' : ''" class="iconfont icon-zitishanchuxian" data-name="strike"></view><view :class="formats.align === 'left' ? 'ql-active' : ''" class="iconfont icon-zuoduiqi" data-name="align"data-value="left"></view><view :class="formats.align === 'center' ? 'ql-active' : ''" class="iconfont icon-juzhongduiqi" data-name="align"data-value="center"></view><view :class="formats.align === 'right' ? 'ql-active' : ''" class="iconfont icon-youduiqi" data-name="align"data-value="right"></view><view :class="formats.align === 'justify' ? 'ql-active' : ''" class="iconfont icon-zuoyouduiqi" data-name="align"data-value="justify"></view><view :class="formats.lineHeight ? 'ql-active' : ''" class="iconfont icon-line-height" data-name="lineHeight"data-value="2"></view><view :class="formats.letterSpacing ? 'ql-active' : ''" class="iconfont icon-Character-Spacing" data-name="letterSpacing"data-value="2em"></view><view :class="formats.marginTop ? 'ql-active' : ''" class="iconfont icon-722bianjiqi_duanqianju" data-name="marginTop"data-value="20px"></view><view :class="formats.previewarginBottom ? 'ql-active' : ''" class="iconfont icon-723bianjiqi_duanhouju" data-name="marginBottom"data-value="20px"></view><view class="iconfont icon-clearedformat" @tap="removeFormat"></view><view :class="formats.fontFamily ? 'ql-active' : ''" class="iconfont icon-font" data-name="fontFamily" data-value="Pacifico"></view><view :class="formats.fontSize === '24px' ? 'ql-active' : ''" class="iconfont icon-fontsize" data-name="fontSize"data-value="24px"></view><view :class="formats.color === '#0000ff' ? 'ql-active' : ''" class="iconfont icon-text_color" data-name="color"data-value="#0000ff"></view><view :class="formats.backgroundColor === '#00ff00' ? 'ql-active' : ''" class="iconfont icon-fontbgcolor"data-name="backgroundColor" data-value="#00ff00"></view><view class="iconfont icon-date" @tap="insertDate"></view><view class="iconfont icon--checklist" data-name="list" data-value="check"></view><view :class="formats.list === 'ordered' ? 'ql-active' : ''" class="iconfont icon-youxupailie" data-name="list"data-value="ordered"></view><view :class="formats.list === 'bullet' ? 'ql-active' : ''" class="iconfont icon-wuxupailie" data-name="list"data-value="bullet"></view><view class="iconfont icon-undo" @tap="undo"></view><view class="iconfont icon-redo" @tap="redo"></view><view class="iconfont icon-outdent" data-name="indent" data-value="-1"></view><view class="iconfont icon-indent" data-name="indent" data-value="+1"></view><view class="iconfont icon-fengexian" @tap="insertDivider"></view><view class="iconfont icon-charutupian" @tap="insertImage"></view><view :class="formats.header === 1 ? 'ql-active' : ''" class="iconfont icon-format-header-1" data-name="header":data-value="1"></view><view :class="formats.script === 'sub' ? 'ql-active' : ''" class="iconfont icon-zitixiabiao" data-name="script"data-value="sub"></view><view :class="formats.script === 'super' ? 'ql-active' : ''" class="iconfont icon-zitishangbiao" data-name="script"data-value="super"></view><view class="iconfont icon-shanchu" @tap="clear"></view><view :class="formats.direction === 'rtl' ? 'ql-active' : ''" class="iconfont icon-direction-rtl" data-name="direction"data-value="rtl"></view></view><view class="editor-wrapper"><editor id="editor" class="ql-container" placeholder="开始输入..." showImgSize showImgToolbar showImgResize@statuschange="onStatusChange" :read-only="readOnly" @ready="onEditorReady"></editor></view></view></view></view>
</template><script>export default {data() {return {readOnly: false,formats: {}}},methods: {readOnlyChange() {this.readOnly = !this.readOnly},onEditorReady() {uni.createSelectorQuery().select('#editor').context((res) => {this.editorCtx = res.context}).exec()},undo() {this.editorCtx.undo()},redo() {this.editorCtx.redo()},format(e) {let {name,value} = e.target.datasetif (!name) return// console.log('format', name, value)this.editorCtx.format(name, value)},onStatusChange(e) {const formats = e.detailthis.formats = formats},insertDivider() {this.editorCtx.insertDivider({success: function() {console.log('insert divider success')}})},clear() {this.editorCtx.clear({success: function(res) {console.log("clear success")}})},removeFormat() {this.editorCtx.removeFormat()},insertDate() {const date = new Date()const formatDate = `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`this.editorCtx.insertText({text: formatDate})},insertImage() {uni.chooseImage({count: 1,success: (res) => {this.editorCtx.insertImage({src: res.tempFilePaths[0],alt: '图像',success: function() {console.log('insert image success')}})}})}},onLoad() {uni.loadFontFace({family: 'Pacifico',source: 'url("https://sungd.github.io/Pacifico.ttf")'})},}
</script><style>@import "./editor-icon.css";.page-body {height: calc(100vh - var(--window-top) - var(--status-bar-height));}.wrapper {height: 100%;}.editor-wrapper {height: calc(100vh - var(--window-top) - var(--status-bar-height) - 140px);background: #fff;}.iconfont {display: inline-block;padding: 8px 8px;width: 24px;height: 24px;cursor: pointer;font-size: 20px;}.toolbar {box-sizing: border-box;border-bottom: 0;font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;}.ql-container {box-sizing: border-box;padding: 12px 15px;width: 100%;min-height: 30vh;height: 100%;margin-top: 20px;font-size: 16px;line-height: 1.5;}.ql-active {color: #06c;}#editor {width: 100%;height: 300px;background-color: #CCCCCC;}
</style>

2.导入css和字体,css和字体已打包上传

uniapp富文本框相关推荐

  1. uniapp 富文本框 获取输入字符长度

    原理很简单,只要通过 textarea 的 @input 事件 就能拿到 所有的参数 图中所示 是输入字符长度 可通过 console.log( e.detail.cursor) 打印 <tem ...

  2. uniapp 电商app 富文本框的使用——添加图文功能

    uniapp 富文本框的使用 uniapp中是有富文本框组件的. uniapp中的富文本框组件的使用官网链接:https://uniapp.dcloud.io/component/editor?id= ...

  3. uniapp 发布文章app 富文本框的使用——添加图文功能

    uniapp 富文本框的使用 uniapp中是有富文本框组件的. uniapp中的富文本框组件的使用官网链接:https://uniapp.dcloud.io/component/editor?id= ...

  4. 若依前后端分离发布富文本框内容 | uni-app微信小程序展示富文本框内容

    微信小程序端引入富文本样式 富文本提交图片json error 一.展示示例: 1.PC端前端发布界面 可以设置文字大小,居中,可以插入图片,设置图片大小,居中. 2.小程序端展示 二.基于若依框架踩 ...

  5. html加载富文本_Uniapp基础实战富文本框解析 WordPress rest api实例

    文本是更具上篇文章uni-app上下拉刷新的续文有需要了解上文的请点击下面连接访问 传送门: Uni-app实战上加载新下拉刷新 WordPress rest api实例 那么我们就开始了,主要的要是 ...

  6. 解决Vue用v-html、v-text渲染后台富文本框文本内容样式修改问题,用自定义css样式无法渲染出对应效果的问题

    举例: 如果您要加载富文本框内容的DOM id是detail 那么就这么写scss样式 #detail {font-size: 14px;text-align: center;&>> ...

  7. 常用的富文本框插件FreeTextBox、CuteEditor、CKEditor、FCKEditor、TinyMCE、KindEditor ;和CKEditor实例...

    目前市面上用的比较多的富文本编辑器有: FreeTextBox 一个有很多年历史的富文本编辑器了,使用简单,而且一般的使用是免费的,但是不开源,上传图片上传附件等功能没有,扩展性差. CuteEdit ...

  8. ueditor 不显示工具栏_Python 之Django富文本框Ueditor的使用

    Django框架是用Python进行Web开发的重要框架,进行Web开发通常会用到网页编辑器,百度的Ueditor网页编辑器功能非常强大,不直接支持python,但有Django第三方插件支持这就是D ...

  9. split、replace、indexof、substr 用法 (获取后台富文本框内容,截取图片)

    1.split()  分割字符串,转化成数组 (1)分割数据中有某段字符串的数据 ,转化成数组 //拿取富文本框中的图片var div=data[0].text.split("/agricu ...

最新文章

  1. Java创建初始化List集合的几种方式
  2. MVC,MVP与MVVM
  3. JAVA与.NET的相互调用——通过Web服务实现相互调用
  4. java开发展望怎么写_Java开发趋势:2019年展望
  5. 将Java类作为子进程运行
  6. 【Verilog HDL】第四章 模块的端口连接规则——污水处理模型
  7. Docker学习总结(69)—— 不用 Docker 如何构建容器
  8. 华为 HMS 上线独立搜索服务;苹果 App Store 出现 Bug ;Ant Design 4.2.5 发布| 极客头条...
  9. 零基础如何快速入门深度学习?
  10. python散点图拟合曲线如何求拟合_python 拟合曲线并求参
  11. TiDB DevCon2018.tick(1.20)
  12. Visual C++ 2010 (中文)学习版 安装教程
  13. MimeType对照表
  14. 程序员常用的网站(个人笔记)
  15. 02H5C3-11. Nginx中部署静态网站
  16. harmonyos bate,HarmonyOS 生态最重的拼图,手机开发者 Beta 版终于到来
  17. 【opencv】背景消除
  18. resultType=int 和 resultType=java.lang.Integer
  19. 医疗系统流程软件测试用例,如何写全流程的测试用例 - rose8561900的个人空间 - 51Testing软件测试网 51Testing软件测试网-软件测试人的精神家园...
  20. Photoshop cs5 基础教程 形状图层的布尔运算

热门文章

  1. springboot整合Thrift
  2. 数据结构:树状数组:姐来展示下什么叫高端前缀和
  3. 转贴:网络游戏封包基础 作者不明
  4. activity间数据传递实例_人品计算器
  5. “Emotion“ 表示【情感】OR【情绪】
  6. Android指示器。
  7. 在2016财年Q1财报前与阿里巴巴CEO张勇深度沟通
  8. 2020-10-15版本(瑕光微明) 明日方舟抽卡模拟器(Python)
  9. 如何在Redis中查找大key
  10. 容器单机编排工具 Docker Compose,swap 限制,配置默认的CFS调度程序,Stress-ng 压力测试工具,docker官网镜像上传,及阿里云镜像上传,Docker 的资源限制