关于在vue项目中使用wangEditor 富文本编辑器
作者:chrispy
sudo npm install wangeditor --save
<div id="editor"></div>
setTimeout(() => {
this.editor = new WangEditor('#editor')
this.editor.customConfig.uploadImgServer = '/qm-server/files/upload'
this.editor.customConfig.uploadFileName = 'file'
this.editor.customConfig.uploadImgParams = {
type: '1'
}
this.editor.customConfig.customUploadImg = (files, insert) => { // 配置上传图片
let formData = new FormData()
formData.append('file', files[0])
formData.append('type', '1')
this.$axios.put('/qm-app/files/upload', formData, { headers: { 'Content-Type': 'multipart/form-data' } }).then(result => {
if (result.data.status === '200') {
insert(result.data.data) // 上传代码返回结果之后,将图片插入到编辑器中
} else {
this.$message.warning(result.data.msg)
return false
}
})
}
if (!this.$route.query.lssueRules) {
this.editor.create()
}
}, 1000)
猜你喜欢
您可能感兴趣的文章:
- mac 10.15 /bin/zsh zsh: fork failed: resource temporarily unavailable
- 利用lrz.bundle.js实现图片压缩上传
- php 数组 Notice: Array to string conversion
- curl或file_get_contents提示failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
- Nginx基本属性配置详解
- vue实现数组上移下移置顶置底
- Error: Record 555612 excessed the excel length limitation of cell
- element el-tree 自定义表格
- git 查看本地仓库路径
- Python Warning: Data truncated for column
- elementUI tree组件获取当前选择所有选中(check)和半选中(indeterminate)的节点
- MYSQL中TRUNCATE和DELETE的区别
- PHP json_encode 空对象和空数组处理
- mac无法将“*.zip”解压到“文件夹”。错误22 无效的参数
- 我的web前端学习之路
- 2019主流的前端框架
- 史上最全的前端学习路线图,干货满满
- javascript学习路线图
- tree 树形结构搜索 显示子集