<template>
<div>
<quill-editor v-model:content="editorContent" contentType="html" />
</div>
</template>
<script setup>
import { ref } from 'vue';
import { QuillEditor } from '@vueup/vue-quill';
import '@vueup/vue-quill/dist/vue-quill.snow.css';
// 定义富文本编辑器的内容
const editorContent = ref('<p>这是一个富文本编辑器的示例。</p>');
</script>
<style scoped>
/* 样式可以根据需要自定义 */
</style>
模板部分 (<template>
):
quill-editor
组件,它是一个基于 Quill.js 的富文本编辑器。v-model:content="editorContent"
绑定了富文本编辑器的内容到 editorContent
变量。contentType="html"
指定了内容类型为 HTML。脚本部分 (<script setup>
):
ref
创建了一个响应式的 editorContent
变量,初始值为一段 HTML 字符串。样式部分 (<style scoped>
):
scoped
属性,使得样式只作用于当前组件。这个示例展示了如何在 Vue 3 中集成和使用一个富文本编辑器。
上一篇:vue富文本编辑器
下一篇:vue reactive
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站