vue editor js
Can change holder ID
Vue-editor-js是Editorjs包裝器組件。
請先查看此。 https://editorjs.io/
該插件是Editorjs的包裝組件。如果您需要將插件用於editor.js,請導入並設置配置屬性。
請參閱演示。
請在main.js中使用Vue.use vue-editor-js。
# NPM
npm install --save vue-editor-js
# or Yarn
yarn add vue-editor-js // ...
import Editor from 'vue-editor-js'
Vue . use ( Editor )
// ... // in nuxt.config.js
plugins: [
{
src : '~/plugins/vue-editor.js' , ssr : false
}
] ,
// in ~/plugins/vue-editor.js
import Vue from 'vue'
import Editor from 'vue-editor-js'
Vue . use ( Editor ) < editor ref="editor" : config = " config " : initialized = " onInitialized " />定義初始化函數以獲取editor.js的實例
如果您與Nuxt一起使用它,請參閱此處
如果您只想在單個組件上導入編輯器,則可以按照以下說明進行操作
@vue/composition-api # NPM
npm i --save @vue/composition-api
# or Yarn
yarn add @vue/composition-api import Vue from 'vue'
import VueCompositionApi from '@vue/composition-api'
Vue . use ( VueCompositionApi )'vue-editor-js'導入任何內容 import { Editor } from 'vue-editor-js'
export default {
// ...
components : {
Editor ,
} ,
// ...
} 與受支持的插件相同,但具有不同的命名
# NPM
npm install --save @editorjs/header
# or Yarn
yarn add @editorjs/header< editor
...
: config = " {
tools: {
header: require ( ' @editorjs/header ' )
}
} "
/>< template >
< div id = " app " >
< Editor ref = " editor " :config = " config " />
< button @click = " invokeSave " >Save</ button >
</ div >
</ template >
< script >
export default {
methods : {
invokeSave () {
this . $refs . editor . _data . state . editor . save ()
. then (( data ) => {
// Do what you want with the data here
console . log (data)
})
. catch ( err => { console . log (err) })
}
},
}
</ script >要上傳圖像,您將需要一個後端來處理圖像。 Vue-editor-js提供了特殊的config道具,以提供可用性。如果要測試服務器上傳圖像,請參見服務器示例。
< editor : config = " config " />
< script >
...
data () {
return {
config : {
image : {
// Like in https://github.com/editor-js/image#config-params
endpoints : {
byFile : ' http://localhost:8090/image ' ,
byUrl : ' http://localhost:8090/image-by-url ' ,
},
field : ' image ' ,
types : ' image/* ' ,
},
}
}
}
</ script > config: {
personality: {
endpoints: 'http://localhost:8090/image'
} 
享受Vue.js項目的Editorjs?
或者
歡迎此存儲庫貢獻者使用wallaby.js oss許可證在輸入時立即獲得測試結果,並在代碼旁邊查看編輯器中的結果。