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.
 
 
 
 
 

47 lines
1.1 KiB

<template lang="html">
<div>
<!-- id="editor1"对应挂载方式EditorInit1 -->
<!-- <div style="color:black;" id="editor1"></div> -->
<!-- ref="editor2"对应挂载方式EditorInit2 -->
<div style="color:black;text-align: left;" ref="editor2"></div>
</div>
</template>
<script>
import E from 'wangeditor'
export default {
methods:{
// WangEditor两种挂载方法,一种挂在id(EditorInit1),一种挂在ref(EditorInit2)
EditorInit1(){
const editor1 = new E ('#editor1');
editor1.create();
},
EditorInit2(){
const temp = this.$refs.editor2;
const editor2 = new E (temp);
editor2.create();
},
mounted(){
//记得在生命周期mounted中加上咱们写的函数,这里用EditorInit1或是EditorInit2都可以
this.EditorInit2();
},
}
}
</script>
<style lang="css">
.editor {
width: 100%;
margin: 0 auto;
position: relative;
z-index: 0;
}
.toolbar {
border: 1px solid #ccc;
}
.text {
border: 1px solid #ccc;
min-height: 500px;
}
</style>