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