這篇文章主要介紹vue中如何使用ueditor富文本編輯器,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
創(chuàng)新互聯(lián)建站專注于企業(yè)營(yíng)銷型網(wǎng)站建設(shè)、網(wǎng)站重做改版、船營(yíng)網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、HTML5建站、商城開(kāi)發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為船營(yíng)等各大城市提供網(wǎng)站開(kāi)發(fā)制作服務(wù)。
Vue具體輕量級(jí)框架、簡(jiǎn)單易學(xué)、雙向數(shù)據(jù)綁定、組件化、數(shù)據(jù)和結(jié)構(gòu)的分離、虛擬DOM、運(yùn)行速度快等優(yōu)勢(shì),Vue中頁(yè)面使用的是局部刷新,不用每次跳轉(zhuǎn)頁(yè)面都要請(qǐng)求所有數(shù)據(jù)和dom,可以大大提升訪問(wèn)速度和用戶體驗(yàn)。
最近在做后臺(tái)管理系統(tǒng)的時(shí)候遇到要使用富文本編輯器。最后選擇了ueditor,我的項(xiàng)目使用 vue+vuex+vue-router+webpack+elementUI的方案完成框架的搭建,
1、下載UEditor官網(wǎng)最新的jsp版本的包,下載完成解壓之后得到一個(gè)utf8-jsp的文件夾,里面包含的內(nèi)容如下:
2、將這個(gè)文件夾改名為ueditor,并且移入自己項(xiàng)目中的static文件夾下,修改ueditor.config.js文件夾中的內(nèi)容,如下圖:
3、編寫子組件
<template> <div :id="id" type="text/plain"></div> </template> <script> import '../../../static/ueditor/ueditor.config.js' import '../../../static/ueditor/ueditor.all.min.js' import '../../../static/ueditor/lang/zh-cn/zh-cn.js' import '../../../static/ueditor/ueditor.parse.min.js' export default { name: 'UE', data() { return { editor: null } }, props: { defaultMsg: { type: String, default: '請(qǐng)輸入內(nèi)容' }, config: { type: Object }, id: { type: String, default: `ue${Math.random(0, 100)}` } }, mounted() { this.$nextTick(() => { this.editor = UE.getEditor(this.id, this.config); // 初始化UE this.editor.addListener("ready", () => { this.editor.execCommand('insertHtml', this.defaultMsg); this.editor.focus() // 確保UE加載完成后,放入內(nèi)容。 }) }) }, methods: { getUEContent() { // 獲取內(nèi)容方法 return this.editor.getContent() }, clearContent() { // 清空編輯器內(nèi)容 return this.editor.execCommand('cleardoc'); }, }, beforeDestroy() { // 組件銷毀的時(shí)候,要銷毀 UEditor 實(shí)例 if (this.editor !== null && this.editor.destroy) { this.editor.destroy(); } } } </script> <style scoped></style>
4、在父組件中使用
<UE :config="configEditor" :id="ue1" ref="ue" :defaultMsg="val"></UE>
5、弄好之后,上傳圖片會(huì)提示后端配置項(xiàng)http錯(cuò)誤,文件上傳會(huì)提示上傳錯(cuò)誤。這里提別申明一點(diǎn),ueditor在前端配置好后,需要與后端部分配合進(jìn)行,然后將配置ueditor.config.js 里的serverUrl的前綴改陳你自己的后端訪問(wèn)的請(qǐng)求路徑地址
serverUrl: "統(tǒng)一請(qǐng)求地址"
以上是“vue中如何使用ueditor富文本編輯器”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
文章題目:vue中如何使用ueditor富文本編輯器
當(dāng)前鏈接:http://jinyejixie.com/article0/gpssoo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、網(wǎng)頁(yè)設(shè)計(jì)公司、全網(wǎng)營(yíng)銷推廣、網(wǎng)站內(nèi)鏈、網(wǎng)站策劃、網(wǎng)站營(yíng)銷
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
營(yíng)銷型網(wǎng)站建設(shè)知識(shí)