当前位置:网站首页>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>
边栏推荐
- 【云原生 | Kubernetes篇】Kubernetes 配置(十五)
- 中部“第一城”,网安长沙以何安网?
- Concept of naive Bayes
- 2022年中总结-一步一个脚印,踩出柳暗花明
- Appareils pris en charge par Arcore
- Haplotype analysis using shapeit
- Optimisation des performances - compression, chargement et formatage des images
- 国金证券开户安全吗?
- 字符串
- The memory allocation of the program, the storage of local const and global const in the system memory, and the perception of pointers~
猜你喜欢

基因型填充前的质控条件简介

Unable to access gcr IO solutions

The backbone of the top 100 security companies! Meichuang technology was selected into the 2022 China top 100 Digital Security Report

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

程序员新人周一优化一行代码,周三被劝退?

JS regular - comb

Es composite query workload evaluation

Unity中的地平面简介

TC software detailed design document (mobile group control)

The bilingual live broadcast of Oriental selection is popular, and the transformation of New Oriental is beginning to take shape
随机推荐
[cloud native | kubernetes] kubernetes configuration (XV)
DSP online upgrade (1) -- understand the startup process of DSP chip
移动应用开发学习通测试题答案
东方甄选双语直播火爆出圈,新东方转型初见端倪
多态&Class对象&注册工厂&反射&动态代理
从零开始做网站11-博客开发
equals 和 hashCode
ESP8266/ESP32 +1.3“ or 0.96“ IIC OLED指针式时钟
如何做一个有趣的人
Audio and video format introduction, encoding and decoding, audio and video synchronization
About Alipay - my savings plan - interest rate calculation instructions
并发底层原理:线程、资源共享、volatile 关键字
123. deep and shallow copy of JS implementation -- code text explanation
流式编程:流支持,创建,中间操作以及终端操作
Xidian AI ranked higher than Qingbei in terms of AI major, and Nantah ranked first in China in terms of Software Science in 2022
Add solid state to the computer
One line of code accelerates sklearn operations thousands of times
异常
Underlying principle of Concurrency: thread, resource sharing, volatile keyword
TC software outline design document (mobile group control)