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许可证在输入时立即获得测试结果,并在代码旁边查看编辑器中的结果。