当前位置:网站首页>Wangedit encapsulation plug-in preliminary
Wangedit encapsulation plug-in preliminary
2022-06-21 10:40:00 【Jimeng network worry free】
install
install editor
yarn add @wangeditor/editor
# perhaps npm install @wangeditor/editor --save
install Vue3 Components
yarn add @wangeditor/editor-for-[email protected]
# perhaps npm install @wangeditor/editor-for-[email protected] --save
In components
If there are other needs , Can be modified by yourself
<template>
<div style="border: 1px solid #ccc">
<Toolbar
style="border-bottom: 1px solid #ccc"
:editor="editorRef"
:defaultConfig="toolbarConfig"
:mode="mode"
/>
<Editor
style="height: 500px; overflow-y: hidden;"
v-model="valueHtml"
:defaultConfig="editorConfig"
:mode="mode"
@onCreated="handleCreated"
/>
</div>
</template>
<script>
import '@wangeditor/editor/dist/css/style.css' // introduce css
import {
onBeforeUnmount, ref, shallowRef, onMounted ,getCurrentInstance} from 'vue'
import {
Editor, Toolbar } from '@wangeditor/editor-for-vue'
const editorRef = shallowRef()
// Content HTML
const valueHtml = ref('<p>hello</p>')
const toolbarConfig = {
}
const editorConfig = {
placeholder: ' Please enter the content ...' }
export default {
components: {
Editor, Toolbar },
data() {
return {
editorRef,
valueHtml,
mode: 'default', // or 'simple'
toolbarConfig,
editorConfig,
}
},
props:{
// Binding value
htmlval: {
},
},
mounted() {
this.parseJv()
},
methods:{
parseJv(){
console.log(this.htmlval)
setTimeout(() => {
valueHtml.value = this.htmlval;// '<p> simulation Ajax Asynchronous setting content </p>'
}, 500)
},
handleCreated(editor) {
editorRef.value = editor // Record editor example , important !
}
},
BeforeUnmount(){
const editor = editorRef.value
if (editor == null) return
editor.destroy()
},
setup() {
// // When components are destroyed , Also destroy the editor in time
// const handleCreated = (editor) => {
// editorRef.value = editor // Record editor example , important !
// }
// return {
// handleCreated
// };
}
}
</script>
quote
<template>
<WangEditor :htmlval="htmlStr" />
</template>
<script>
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
import WangEditor from './components/form/WangEditor.vue'
export default {
components: {
WangEditor },
data() {
return {
htmlStr: '<p>helloasd1</p>',
}
},
}
</script>
边栏推荐
- Inner class
- 中部“第一城”,网安长沙以何安网?
- 触摸按键控制器TTP229-BSF使用心得[原创cnblogs.com/helesheng]
- Eig and Saudi Aramco signed a memorandum of understanding to expand energy cooperation
- WCF restful+jwt authentication
- wangeditor封装插件初步
- Optimisation des performances - compression, chargement et formatage des images
- Do website from scratch 11- blog development
- Vscode high-speed download address -- solve the problem of slow vscode Download
- 程序員新人周一優化一行代碼,周三被勸退?
猜你喜欢

ESP8266/ESP32 +1.3“ or 0.96“ IIC OLED指针式时钟

DSP online upgrade (2) -- design framework of bootloader

China international e-commerce center and Analysys jointly released: the national online retail development index in the fourth quarter of 2021 increased by 0.6% year on year

香农的信息论究竟牛在哪里?

123. deep and shallow copy of JS implementation -- code text explanation

One line of code accelerates sklearn operations thousands of times

NLog自定义Target之MQTT

性能优化——图片压缩、加载和格式选择

Les nouveaux programmeurs optimisent une ligne de code lundi et sont exhortés à se retirer mercredi?
![FastAPI Web框架 [Pydantic]](/img/e1/290a8a6a978b9fb56a9c86f1734c45.png)
FastAPI Web框架 [Pydantic]
随机推荐
开课报名|「Takin开源特训营」第一期来啦!手把手教你搞定全链路压测!
121. Redux detailed summary + effect drawing + Case
Why does C throw exceptions when accessing null fields?
Black Monday
如何将MindSpore模型转ONNX格式并使用OnnxRuntime推理---开发测试篇
香农的信息论究竟牛在哪里?
Odd number of characters异常
Equals and hashcode
Advanced part of concurrent programming: parallel flow, tasks and executors, and completabilefuture classes
Matplotlib 绘制圆环图的两种方法!
2. MySQL index optimization
WCF restful+jwt authentication
Inner class
如何做一个有趣的人
The "first city" in Central China. How can Changsha be built?
poi实现操作生成word表格和操作word中的图表数据
Three elements of basic concepts and methods of machine learning
Introduction and template of segment tree Foundation (I)
ArCore支持的设备
Original code, inverse code, complement calculation function applet; C code implementation;