vue中引入ueditor
1.放入静态资源并配置
首先把官网下载的Ueditor资源,放入静态资源src/static中。(你的U盘里有,不用下载了)
2.封装一个组件 ueditor.vue ,放到src/components/里
<template>
<div>
<script id="editor" type="text/plain"/>
</div>
</template>
<script>
import '../../static/ueditor/ueditor.config.js'
import '../../static/ueditor/ueditor.all.js'
import '../../static/ueditor/lang/zh-cn/zh-cn.js'
import '../../static/ueditor/ueditor.parse.min.js'
export default {
props: {
initData: {
type: String
}
},
data () {
return {
editor: null
}
},
watch: {
initData: function (val) {
let con = val ? val : ''
this.editor.ready(() => {
this.editor.setContent(con)
})
}
},
mounted () {
this.setConfig()
},
methods: {
// 获取内容