快速开始
Umo-Editor 是一个基于 Vue3 的文档编辑器。 您可以访问https://demo.umodoc.com/editor,体验和测试 Umo-Editor 的部分功能。
安装
使用 NPM 安装
npm install --save @umoteam/editor
⚠️
注意:自 v3.0 版本开始,Umo Editor 取消了对 UMD 版本的支持。
使用
以下使用方式任选一种即可:
全局安装
main.js
import { createApp } from 'vue';
import { useUmoEditor } from '@umoteam/editor';
const app = createApp(App);
app.use(useUmoEditor, {
// 配置项
// ...
});
app.mount('#app');
直接引入
以下组合式 API 和选项式 API 的 JS 示例任选一种使用。
component.vue
<template>
<umo-editor v-bind="options" />
<!-- 或者 -->
<!--
<umo-editor
:editor-key="options.editorKey"
...
/> -->
</template>
// 使用组合式 API
<script setup>
import { ref } from 'vue'
import { UmoEditor } from '@umoteam/editor';
const options = ref({
// 配置项
// ...
});
</script>
// 或使用选项式 API
<script>
import { UmoEditor } from '@umoteam/editor';
export default {
components: {
UmoEditor
},
data() {
return {
options: {
// 配置项
// ...
}
}
}
}
</script>
在 Nuxt3 中使用
安装
npx nuxi module add @umoteam/umo-editor-nuxt
# 或
npm i @umoteam/umo-editor-nuxt
使用
- 安装和配置
@umoteam/umo-editor-nuxt
模块
nuxt.config.ts
export default defineNuxtConfig({
modules: ['@umoteam/umo-editor-nuxt'],
umoEditor: {
// 全局配置项,默认配置见:
// https://editor.umodoc.com/cn/docs/options/default
locale: 'en-US',
},
})
- 使用 Umo Editor 组件
<template>
<div style="height: 600px;">
<UmoEditor v-bind="options" />
</div>
</template>
<script setup>
const options = ref({
// 配置项,见:
// https://editor.umodoc.com/cn/docs/options/default
})
</script>
配置
见配置项。