vue项目中使用百度富文本编辑器ueditor
2024-08-23 18:44:24
第一步,安装依赖,并且把ueditor整个文件夹放入public里边
第二步,在你需要编辑的地方引入,或者main.js中全局引入
XX.vue文件中写入下面代码,创建编辑器。
<vue-ueditor-wrap v-model="form.content" :config="myConfig" @ready='ueditor'></vue-ueditor-wrap>
第三步,在script中引入
import VueUeditorWrap from 'vue-ueditor-wrap'
第四步,在export default {}中加入
omponents: { VueUeditorWrap },
然后在data(){}中添加工具栏等配置文件
第五步,在methods:{}中配置请求参数,以携带token啥的
ueditor (ueditor) {
ueditor.execCommand('serverparam', ueditor => {
return {
userToken: window.sessionStorage.getItem('userToken'),
Rtoken: window.sessionStorage.getItem('Rtoken')
}
})
完整配置
<template>
<vue-ueditor-wrap v-model="form.content" :config="myConfig" @ready='ueditor'></vue-ueditor-wrap>
</template> <script>
import VueUeditorWrap from 'vue-ueditor-wrap'
export default {
name: 'ueditor',
omponents: { VueUeditorWrap },
data () {
return {
myConfig: {
serverUrl: '',
UEDITOR_HOME_URL: '/editor/',
autoHeightEnabled: true,
autoFloatEnabled: false,
initialFrameHeight: 540,
initialFrameWidth: '100%',
maximumWords: 2000,
enableAutoSave: true,
toolbars: [[
'fontfamily', // 字体
'fontsize',
'bold', // 加粗
'indent', // 首行缩进
'justifyleft', // 居左对齐
'justifyright', // 居右对齐
'justifycenter', // 居中对齐
'forecolor',
'link',
'insertorderedlist',
'insertunorderedlist',
'insertcode',
'spechars', // 特殊字符
'pagebreak', // 分页
'attachment', // 附件
'imagecenter', // 居中
'wordimage', // 图片转存
'time',
'date' ]]
}
}
},
methods: {
ueditor (ueditor) {
ueditor.execCommand('serverparam', ueditor => {
return {
userToken: window.sessionStorage.getItem('userToken'),
Rtoken: window.sessionStorage.getItem('Rtoken')
}
})
}
}
}
</script>
最新文章
- 请写一个php函数,可以接受任意数量的参数
- C#窗体->;>;随机四则运算
- hiho1099_constellation
- 【kate总结】matlab调用opencv总结
- 【高斯消元】Poj 1222:EXTENDED LIGHTS OUT
- Visual Studio中的一些较大的文件的作用
- linux 多核
- 四维dp 或者 剪枝 + dfs Codeforces Beta Round #6 (Div. 2 Only) D
- 计算机 计算机语言 常见的DOS命令
- [0] C#异常种类
- Python学习—框架篇之初识Django
- window下安装PIL
- 强大的JQuery表单验证插件 FormValidator使用介绍
- mark一下岗位
- 用TexturePacker打图集用于UGUI中
- redis 超时失效key 的监听触发
- [javaSE] 网络编程(URL)
- Action的方法访问
- Continuous Subarray Sum II(LintCode)
- atitit.《金刚经》与it软件项目管理的启发 读后感attilax
热门文章
- ASPNET Core笔试题
- android studio 初印象
- VS无线振弦采集仪的常见问题
- k8s+crio+podman搭建集群
- 云ATM架构设计
- 【每天学一点-05】使用umi.js代理,解决跨域问题(前端)
- Java开发学习(二十一)----Spring事务简介与事务角色解析
- Vue3 computed &;&; watch(watchEffect)
- springboot的@ConditionalOnClass注解
- Java学习 (四)基础篇 Java基础语法