1. main.js引入vue-quill-editor

import  VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css' Vue.use(VueQuillEditor)

2. 具体代码

<template>
  <quill-editor v-model="txt" ref="richAnalysis" :options="options"></quill-editor>
</template>
export default {
  data() {
    return {
      txt: '',
      options: {
        modules: {
          toolbar: [
            ['bold', 'italic', 'underline', 'strike', {'script': 'sub'}, {'script': 'super'}]
           ]
          },
          placeholder: '请输入内容'
        }
    }
  },
  mounted() {
    //  阻止光标默认选中
    this.$refs.richAnalysis.quill.enable(false);
    setTimeout(() => {
      this.$refs.richAnalysis.quill.enable(true);
      this.$refs.richAnalysis.quill.blur();
    }, 200)
  }
}

3. 光标处插入内容,光标位置向前移动一位

    addBlock() {
document.execCommand('insertText', true, '{q:}')  //  光标处插入内容{q:}
this.$nextTick(() => {
const index = this.$refs.richAnalysis.quill.selection.savedRange.index
this.$refs.richAnalysis.quill.setSelection(index -1, 0)  //  光标位置移动到冒号之后
})
}

最新文章

  1. .net core Jwt 添加
  2. UVa401 回文词
  3. hdu2368Alfredo&#39;s Pizza Restaurant
  4. HDU4911-Inversion(树状数组)
  5. automaticallyAdjustsScrollViewInsets (iOS)
  6. AJAX(XMLHttpRequest)进行跨域请求方法详解(三)
  7. 支持苹果IPV6 ONLY 的socket 修改方法
  8. SQL Server 执行计划操作符详解(1)——断言(Assert)
  9. Httpclient发送json请求
  10. 性能测试学习 第八课--LR12中针对WebServices协议的三种脚本开发模式
  11. Dungeon Master (广搜)
  12. Form-encoded method must contain at least one @Field.
  13. java多线程快速入门(九)
  14. 总结5条对学习Linux系统有帮助的经验心得
  15. spring事务中出现oracle游标溢出的解决方案
  16. Vue2.5开发去哪儿网App 第二章笔记
  17. 树莓派开发系列教程2--树莓派3B介绍及系统烧写、基本配置
  18. 【重点】Jmeter----- 将 JDBC Request 查询结果作为下一个接口参数方法(二)
  19. list 往指定的下标插入元素
  20. SQL注入点的类型

热门文章

  1. 【静态延迟加载】self关键字和static关键字的区别
  2. Linux 安装MySQL流程
  3. Codeforces 1247C. p-binary
  4. git、git bash、git shell
  5. 数据库优化方案之SQL脚本优化
  6. html中script标签使用async属性和defer属性的区别
  7. winForm入门学习
  8. vue-cli3 本地数据模拟后台接口
  9. mysql 利用 case 批量更新
  10. jmeter连接mysql数据库进行单条语句查询