最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue2中使用quill編輯器+表格功能(步驟詳解)

 更新時間:2023年09月14日 10:13:12   作者:齊旗  
這篇文章主要介紹了vue2中使用quill編輯器+表格功能,本文分步驟結(jié)合實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

注意:現(xiàn)在quill2才能支持表格功能,quill2官方未發(fā)布正式版本,現(xiàn)在是開發(fā)版本

步驟一:安裝quill

$npm install quill@2.0.0-dev.3 -dev–save

步驟二:創(chuàng)建edtior.vue組件

<template>
	<div>
		<div class="editor" style="height: 1000px"></div>
	</div>
</template>
<script>
import Quill from 'quill'
import 'quill/dist/quill.snow.css'
export default {
  name: 'Editor',
  props: {
    content: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      quill: null,
      options: {
        theme: 'snow',
        modules: {
          toolbar: {
            container: [
              ['bold', 'italic', 'underline', 'strike'],
              [{ header: 1 }, { header: 2 }],
              [{ color: [] }, { background: [] }],
              [{ list: 'ordered' }, { list: 'bullet' }],
              [{ align: [] }],
              [{ indent: '-1' }, { indent: '+1' }],
              ['link','image','video'],
              [
                { table: 'TD' },
                { 'table-insert-row': 'TIR' },
                { 'table-insert-column': 'TIC' },
                { 'table-delete-row': 'TDR' },
                { 'table-delete-column': 'TDC' }
              ],
            ],
            handlers: {
              table: function (val) {
                this.quill.getModule('table').insertTable(2, 3)
              },
              'table-insert-row': function () {
                this.quill.getModule('table').insertRowBelow()
              },
              'table-insert-column': function () {
                this.quill.getModule('table').insertColumnRight()
              },
              'table-delete-row': function () {
                this.quill.getModule('table').deleteRow()
              },
              'table-delete-column': function () {
                this.quill.getModule('table').deleteColumn()
              }
            }
          },
          table: true
        },
        placeholder: ''
      }
    }
  },
  mounted () {
    console.log(this.content)
    const dom = this.$el.querySelector('.editor')
    this.quill = new Quill(dom, this.options)
    // this.quill.setContents(this.content)
    // debugger
    this.quill.root.innerHTML = this.content
    // debugger
    this.quill.on('text-change', () => {
    //   console.log(this.quill.getContents())
    //   this.$emit('contentData', this.quill.getContents())
    //   console.log(this.quill.root.innerHTML)
      this.$emit('contentData', this.quill.root.innerHTML)
    })
    this.$el.querySelector(
      '.ql-table-insert-row'
    ).innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="24" height="24" viewBox="0 0 24 24"><defs><clipPath id="master_svg0_152_6483"><rect x="0" y="0" width="24" height="24" rx="0"/></clipPath></defs><g clip-path="url(#master_svg0_152_6483)"><g><path d="M10,3C10.552,3,11,3.448,11,4L11,20C11,20.552,10.552,21,10,21L4,21C3.448,21,3,20.552,3,20L3,4C3,3.448,3.448,3,4,3L10,3ZM9,5L5,5L5,19L9,19L9,5ZM18,7C20.761,7,23,9.239,23,12C23,14.761,20.761,17,18,17C15.239,17,13,14.761,13,12C13,9.239,15.239,7,18,7ZM19,9L17,9L17,10.998999999999999L15,11L15,13L17,12.999L17,15L19,15L19,12.999L21,13L21,11L19,10.998999999999999L19,9Z" fill="#444444" fill-opacity="1"/></g></g></svg>`
    this.$el.querySelector(
      '.ql-table-insert-column'
    ).innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="24" height="24" viewBox="0 0 24 24"><defs><clipPath id="master_svg0_152_6487"><rect x="0" y="0" width="24" height="24" rx="0"/></clipPath></defs><g clip-path="url(#master_svg0_152_6487)"><g><path d="M12,13C14.761,13,17,15.239,17,18C17,20.761,14.761,23,12,23C9.239,23,7,20.761,7,18C7,15.239,9.239,13,12,13ZM13,15L11,15L11,16.999000000000002L9,17L9,19L11,18.999000000000002L11,21L13,21L13,18.999000000000002L15,19L15,17L13,16.999000000000002L13,15ZM20,3C20.552,3,21,3.448,21,4L21,10C21,10.552,20.552,11,20,11L4,11C3.448,11,3,10.552,3,10L3,4C3,3.448,3.448,3,4,3L20,3ZM5,5L5,9L19,9L19,5L5,5Z" fill="#444444" fill-opacity="1"/></g></g></svg>`
    this.$el.querySelector(
      '.ql-table-delete-row'
    ).innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="24" height="24" viewBox="0 0 24 24"><defs><clipPath id="master_svg0_152_6479"><rect x="0" y="0" width="24" height="24" rx="0"/></clipPath></defs><g clip-path="url(#master_svg0_152_6479)"><g><path d="M20,3C20.552,3,21,3.448,21,4L21,20C21,20.552,20.552,21,20,21L14,21C13.448,21,13,20.552,13,20L13,4C13,3.448,13.448,3,14,3L20,3ZM19,5L15,5L15,19L19,19L19,5ZM6,7C8.761,7,11,9.239,11,12C11,14.761,8.761,17,6,17C3.239,17,1,14.761,1,12C1,9.239,3.239,7,6,7ZM7,9L5,9L5,10.998999999999999L3,11L3,13L5,12.999L5,15L7,15L7,12.999L9,13L9,11L7,10.998999999999999L7,9Z" fill="#444444" fill-opacity="1"/></g></g></svg>`
    this.$el.querySelector(
      '.ql-table-delete-column'
    ).innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="24" height="24" viewBox="0 0 24 24"><defs><clipPath id="master_svg0_152_6491"><rect x="0" y="0" width="24" height="24" rx="0"/></clipPath></defs><g clip-path="url(#master_svg0_152_6491)"><g><path d="M20,13C20.552,13,21,13.448,21,14L21,20C21,20.552,20.552,21,20,21L4,21C3.448,21,3,20.552,3,20L3,14C3,13.448,3.448,13,4,13L20,13ZM19,15L5,15L5,19L19,19L19,15ZM12,1C14.761,1,17,3.239,17,6C17,8.761,14.761,11,12,11C9.239,11,7,8.761,7,6C7,3.239,9.239,1,12,1ZM13,3L11,3L11,4.9990000000000006L9,5L9,7L11,6.999L11,9L13,9L13,6.999L15,7L15,5L13,4.9990000000000006L13,3Z" fill="#444444" fill-opacity="1"/></g></g></svg>`
    this.addQuillTitle()
  },
  activated () {
    this.quill.setContents({})
  },
  methods: {
    addQuillTitle () {
      const oToolBar = document.querySelector('.ql-toolbar')
      const aButton = oToolBar.querySelectorAll('button')
      const aSelect = oToolBar.querySelectorAll('select')
      aButton.forEach(function (item) {
        if (item.className === 'ql-script') {
          item.value === 'sub' ? (item.title = '下標(biāo)') : (item.title = '上標(biāo)')
        } else if (item.className === 'ql-indent') {
          item.value === '+1' ? (item.title = '向右縮進') : (item.title = '向左縮進')
        } else {
          item.title = titleConfig[item.classList[0]]
        }
      })
      aSelect.forEach(function (item) {
        item.parentNode.title = titleConfig[item.classList[0]]
      })
    },
    getContentData () {
      return this.quill.getContents()
    }
  }
}
</script>
<style>
</style>

步驟三:引用該組件的父組件

<template>
    <quillEditor v-if="content" :model-value="content" @input="editorChange"/>
</template>
<script>
import quillEditor from '@/components/quillEditor/editor.vue'
export default {
    data() {
        return {
            content: ''
        }
    },
    methods: {
        contentChange(data) {
		    this.content = data
	    },
    }
}
</script>

到此這篇關(guān)于vue2中使用quill編輯器+表格功能的文章就介紹到這了,更多相關(guān)vue使用quill編輯器內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • vue組件引用另一個組件出現(xiàn)組件不顯示的問題及解決

    vue組件引用另一個組件出現(xiàn)組件不顯示的問題及解決

    這篇文章主要介紹了vue組件引用另一個組件出現(xiàn)組件不顯示的問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • 詳解vue3.0 diff算法的使用(超詳細(xì))

    詳解vue3.0 diff算法的使用(超詳細(xì))

    這篇文章主要介紹了詳解vue3.0 diff算法的使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • vue3父組件和子組件如何傳值實例詳解

    vue3父組件和子組件如何傳值實例詳解

    近期學(xué)習(xí)vue3的父子組件之間的傳值,發(fā)現(xiàn)跟vue2.x的父子組件之間的傳值并沒有太大的區(qū)別,下面這篇文章主要給大家介紹了關(guān)于vue3父組件和子組件如何傳值的相關(guān)資料,需要的朋友可以參考下
    2022-08-08
  • Vue+Openlayer使用modify修改要素的完整代碼

    Vue+Openlayer使用modify修改要素的完整代碼

    這篇文章主要介紹了Vue+Openlayer使用modify修改要素的完整代碼,代碼簡單易懂,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-09-09
  • vue+iview動態(tài)渲染表格詳解

    vue+iview動態(tài)渲染表格詳解

    這篇文章主要為大家詳細(xì)介紹了vue+iview動態(tài)渲染表格的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-03-03
  • Vue3 封裝回到頂部組件的實現(xiàn)示例

    Vue3 封裝回到頂部組件的實現(xiàn)示例

    回到頂部在很多網(wǎng)頁中都可以見到,本文主要介紹了Vue3 封裝回到頂部組件的實現(xiàn)示例,文中根據(jù)實例編碼詳細(xì)介紹的十分詳盡,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • Vue中插槽和過濾器的深入講解

    Vue中插槽和過濾器的深入講解

    Vue插槽,是學(xué)習(xí)vue中必不可少的一節(jié),越來越發(fā)現(xiàn)插槽的好用,而過濾數(shù)據(jù)也是我們?nèi)粘i_發(fā)中必然會用到的,這篇文章主要給大家介紹了關(guān)于Vue插槽和過濾器的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2021-07-07
  • vue防止花括號{{}}閃爍v-text和v-html、v-cloak用法示例

    vue防止花括號{{}}閃爍v-text和v-html、v-cloak用法示例

    這篇文章主要介紹了vue防止花括號{{}}閃爍v-text和v-html、v-cloak用法,結(jié)合實例形式分析了vue.js使用v-text和v-html、v-cloak防止花括號{{}}閃爍的解決方法,需要的朋友可以參考下
    2019-03-03
  • vue+Element-ui實現(xiàn)分頁效果

    vue+Element-ui實現(xiàn)分頁效果

    這篇文章主要為大家詳細(xì)介紹了vue+Element-ui實現(xiàn)分頁效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-11-11
  • Vue3中reactive與ref函數(shù)使用場景

    Vue3中reactive與ref函數(shù)使用場景

    這篇文章主要為大家介紹了Vue3?中有場景是?reactive?能做而?ref?做不了的使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-07-07

最新評論

鄂托克前旗| 屯门区| 保靖县| 松溪县| 南安市| 突泉县| 富裕县| 东乡族自治县| 贵州省| 图木舒克市| 望奎县| 大连市| 内丘县| 平邑县| 弋阳县| 云安县| 台前县| 额尔古纳市| 措美县| 偃师市| 苏尼特右旗| 阳春市| 蓬莱市| 聊城市| 三都| 平和县| 进贤县| 池州市| 昭通市| 错那县| 南川市| 布拖县| 喀喇| 汤阴县| 苍南县| 印江| 宁蒗| 双流县| 淅川县| 华容县| 禹城市|