vue2-editor的入門使用
準備工做: 使用 npm install vue2-editor --save 安裝到項目中去;vue
在須要的單文件內引入 import { VueEditor } from 'vue2-editor',
註冊組件git
components: { VueEditor }, <vue-editor v-model="content" :editorToolbar="customToolbar"> </vue-editor> data() { return { content: '', customToolbar: [ ['bold', 'italic', 'underline'], [{ 'list': 'ordered' }, { 'list': 'bullet' }], [{ 'indent': '-""' }, { 'indent': '+""' }], [{ 'header': '2' }], ['clean'], [{ 'align': 'center' }, { 'align': 'justify' }, { 'align': 'right' }] ], } }
<template> <div id="app"> <vue-editor v-model="content"></vue-editor> </div> </template> <script> import { VueEditor } from "vue2-editor"; export default { components: { VueEditor }, data() { return { content: "<h1>Some initial content</h1>" }; } }; </script>
注意事項:github
對於這個上面的customToolbar的修改,有的內容不須要,能夠經過鼠標拾取來定義,顯示的內容
參考文檔:
https://www.vue2editor.com/ex...
https://github.com/davidroyer...npm