编辑器保存后,销毁canvas画布

This commit is contained in:
red-deng-deng 2022-01-14 10:40:25 +08:00
parent aec000eafc
commit aad48adcaf
2 changed files with 9 additions and 6 deletions

View File

@ -341,7 +341,6 @@ getLandingdata(val){
let path = null; let path = null;
let canvasEle=this.canvasImg;  //获取元素 let canvasEle=this.canvasImg;  //获取元素
let scrolDom=this.canvascrol; let scrolDom=this.canvascrol;
console.log(351,this);
scrolDom.scrollTop = 0; scrolDom.scrollTop = 0;
let dom=document.querySelector('.xj-viewer-mask'); let dom=document.querySelector('.xj-viewer-mask');
let dom2=document.querySelector('.editor-main'); let dom2=document.querySelector('.editor-main');
@ -357,7 +356,6 @@ getLandingdata(val){
}).then(async (canvas) => { }).then(async (canvas) => {
//处理你生成的canvas //处理你生成的canvas
document.body.appendChild(canvas); document.body.appendChild(canvas);
let a = document.createElement('a');
let file = canvas.toDataURL( ); let file = canvas.toDataURL( );
let thumbimg= self.dataURLtoFile(file,'image/png'); let thumbimg= self.dataURLtoFile(file,'image/png');
let imgformdata= new FormData(); let imgformdata= new FormData();
@ -479,7 +477,11 @@ getLandingdata(val){
}; };
componentWillUnmount(){
if(document.querySelector('canvas')){
document.querySelector('canvas').remove();
}
}
render(){ render(){

View File

@ -14,9 +14,10 @@ export default class wangeditor extends React.Component{
const editor = new Editor('#wangeditorDom') const editor = new Editor('#wangeditorDom')
this.setState({editor}); this.setState({editor});
editor.config.colors = [ editor.config.colors = [
'#880000', '#696969',
'#800080', '#9093a2',
'#ff0000' '#fgddbb',
'#e3e7eb'
]; ];
editor.config.pasteText = true; editor.config.pasteText = true;
// 设置编辑区域高度为 500px // 设置编辑区域高度为 500px