生活随笔
收集整理的這篇文章主要介紹了
如何在vue-cli3中使用tinymce
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
腳手架vue-cli3 首先安裝 npm install tinymce@5.4.2 @tinymce/tinymce-vue@3.2.2 -S
安裝成功后,在node_modules目錄中,查找tinymce/skins目錄,將skins目錄拷貝到public目錄下。 并到官網(wǎng)中下載中文語(yǔ)言包找到zh_CN.JS拷貝出來(lái) 然后在components中創(chuàng)建文件夾tinymce和tinymce.vue 在組件中寫配置
< template
> < div
class = "tinymce-editor" > < editor id
= "tinymce" v
- model
= "myValue" : init
= "init" @onClick
= "onClick" > < / editor
> < / div
>
< / template
> < script
>
import tinymce
from 'tinymce/tinymce' import Editor
from '@tinymce/tinymce-vue' import 'tinymce/themes/silver/theme.min.js' import 'tinymce/icons/default/icons' import 'tinymce/plugins/image' import 'tinymce/plugins/media' import 'tinymce/plugins/table' import 'tinymce/plugins/lists' import 'tinymce/plugins/wordcount' import 'tinymce/plugins/link' import 'tinymce/plugins/code' import 'tinymce/plugins/preview' import 'tinymce/plugins/fullscreen' import 'tinymce/plugins/help' export default { components
: { Editor
} , name
: 'Tinymce' , props
: { value
: { type
: String
, default : '' } , baseUrl
: { type
: String
, default : window
. location
. origin
? window
. location
. origin
: '' } , disabled
: { type
: Boolean
, default : false } , plugins
: { type
: [ String
, Array
] , default : 'link lists image code table wordcount media preview fullscreen help' } , toolbar
: { type
: [ String
, Array
] , default : 'undo redo | formatselect | bold italic underline | forecolor backcolor | link unlink code lists table image | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent blockquote | removeformat | fullscreen preview' } , height
: { type
: Number
, default : 500 } } , data ( ) { return { init
: { language_url
: ` ${ this . baseUrl} /tinymce/zh_CN.js` , language
: 'zh_CN' , skin_url
: ` ${ this . baseUrl} /tinymce/skins/ui/oxide` , convert_urls
: false , height
: this . height
, plugins
: this . plugins
, toolbar
: this . toolbar
, statusbar
: true , menubar
: 'file edit insert view format table tools' , branding
: false , paste_data_images
: true , images_upload_handler
: ( blobInfo
, success
, failure
) => { const formData
= new FormData ( ) ; formData
. append ( 'file' , blobInfo
. blob ( ) ) ; this . axios ( { method
: 'post' , url
: 'http://47.109.23.138:8300/upload/upFileImg' , data
: formData
, } ) . then ( function ( res
) { console
. log ( res
. data
. data
) let file
= res
. data
. data
; success ( file
. src
) ; } ) . catch ( function ( err
) { console
. log ( err
) } ) } } , myValue
: this . value
} ; } , mounted ( ) { tinymce
. init ( { } ) ; } , methods
: { onClick ( e
) { this . $emit ( 'onClick' , e
, tinymce
) ; } , clear ( ) { this . myValue
= '' ; } } , watch
: { value ( newValue
) { this . myValue
= newValue
; } , myValue ( newValue
) { this . $emit ( 'input' , newValue
) ; } }
} ;
< / script
>
然后在其他頁(yè)面中使用
< template
> < div
class = "home" > < tinymce style
= "width: 100%;" id
= "myedit" ref
= "editor" : height
= "300" : disabled
= "disabled" : toolbar
= "toolbar" input
= "input" / > < / div
>
< / template
> < script
>
import Tinymce
from '../components/tinymce/tinymce' ; export default { name
: 'Home' , components
: { Tinymce
} ,methods
: { input ( ) { console
. log ( this . $refs
. editor
. myValue
) } }
}
< / script
>
總結(jié)
以上是生活随笔 為你收集整理的如何在vue-cli3中使用tinymce 的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺(jué)得生活随笔 網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔 推薦給好友。