基于vue3、Element Plus和TypeScript构建的HTML5富文本编辑器

vue-vuecmf-editor是一款基于vue3、Element Plus和TypeScript构建的HTML5富文本编辑器。

使用说明文档:

组件 | VueCMF基于vue3、element plus、typescript开发的vuecmf相关组件:vue-vuecmf-dialog弹窗组件、vue-vuecmf-editor富文本编辑器、vue3-vuecmf-table多功能列表组件。icon-default.png?t=M3C8http://www.vuecmf.com/components/#%E4%BB%8B%E7%BB%8D-2

效果展示:

 

 安装

yarn add vue-vuecmf-editor

 在项目中使用

1、导入组件

在vue3项目中 main.ts 引入,如下

import { createApp } from 'vue'
import App from './App.vue'
import './registerServiceWorker'

//导入
import VuecmfEditor from "vue-vuecmf-editor"

createApp(App).use(VuecmfEditor).mount('#app')

2、然后在模板文件中使用

<template>
  <h3>vuecmf-editor demo</h3>

  <vuecmf-editor
      id="myeditor"
      :content="contentHtml"
      @on-change="getContent"
  ></vuecmf-editor>
  <button @click="save">保存</button>

</template>


<script lang="ts">
import {defineComponent, ref} from 'vue';

export default defineComponent({
  name: 'App',
  components: {
  },
  setup(){
    const contentHtml = ref('Hello world!')

    const getContent = (content:string, id: string) => {
      console.log('id=', id)
      contentHtml.value = content
    }

    const save = ():void => {
      alert(contentHtml.value)
    }

    return {
      getContent,
      contentHtml,
      save
    }

  }
});
</script>

组件中的属性和事件可参考使用说明文档。 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue 3是Vue.js的最新版本,它带来了许多令人兴奋的新特性和改进。Element Plus是一套基于Vue 3的UI组件库,它是对Element UI的升级和重构。TypeScript是一种静态类型检查的编程语言,可以帮助我们在开发过程中更加安全和高效地编写代码。Vite是一个新型的前端构建工具,它可以提供快速的开发体验和更好的性能。 如果你想在Vue 3项目中使用Element Plus和TypeScript,可以按照以下步骤进行: 1. 创建一个新的Vue 3项目。你可以使用Vue CLI来创建项目: ``` $ vue create my-project ``` 2. 在项目中安装Element Plus。你可以使用npm或yarn来安装: ``` $ npm install element-plus 或 $ yarn add element-plus ``` 3. 在项目的入口文件(通常是main.ts)中引入Element Plus的样式和组件: ```typescript import { createApp } from 'vue'; import ElementPlus from 'element-plus'; import 'element-plus/lib/theme-chalk/index.css'; const app = createApp(App); app.use(ElementPlus); app.mount('#app'); ``` 4. 开始在项目中使用Element Plus的组件。你可以在Vue组件中按需引入所需的组件,例如: ```vue <template> <el-button type="primary">Button</el-button> </template> <script> import { defineComponent } from 'vue'; import { ElButton } from 'element-plus'; export default defineComponent({ components: { ElButton } }); </script> ``` 5. 如果你想在项目中使用TypeScript,可以将项目的脚手架配置为支持TypeScript。在Vue CLI创建项目时,可以选择TypeScript作为预设选项。如果你已经创建了项目,可以手动添加TypeScript支持,具体步骤可以参考Vue官方文档。 希望以上步骤对你有帮助!如果还有其他问题,请随时向我提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值