You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

70 lines
1.7 KiB

<template lang="html">
<div id="editor" name="productcontent"></div>
</template>
<script>
import {BASE_API} from '../../config';
// import E from 'wangEditor'
import E from './wangEditor.min.js'
export default {
name: 'editoritem',
props:{
content:{
type: String,
default: ''
}
},
data() {
return {
// uploadPath,
editor: null,
}
},
watch: {
content(val){
if(val){
this.editor.txt.html(val)
}
}
},
mounted() {
this.seteditor()
this.editor.txt.html(this.content)
},
methods: {
seteditor() {
this.editor = new E( document.getElementById('editor') )
this.editor.config.height = 800
this.editor.config.uploadImgShowBase64 = false // base 64 存储图片
this.editor.config.uploadImgServer = `${BASE_API}/file/uploadImg`// 配置服务器端地址
this.editor.config.uploadVideoServer = `${BASE_API}/file/uploadAudio`
this.editor.config.uploadVideoName = 'file'
this.editor.config.uploadFileName = 'file' // 后端接受上传文件的参数名
this.editor.config.uploadImgMaxSize = 2 * 1024 * 1024 // 将图片大小限制为 2M
this.editor.config.uploadImgMaxLength = 1 // 限制一次最多上传 1 张图片
this.editor.config.uploadImgTimeout = 3 * 60 * 1000 // 设置超时时间
this.editor.create()
},
getValue(){
return this.editor.txt.html()
}
}
}
</script>
<style lang="css" scoped>
.editor {
width: 100%;
margin: 0 auto;
position: relative;
}
.toolbar {
border: 1px solid #ccc;
}
.text {
border: 1px solid #ccc;
min-height: 500px;
}
</style>