1安装
npm install mavon-editor --save
网址:官网
html
<mavon-editor
v-if="zuJianWD"
:editable="false"
:value="zuJianWD"
:subfield="false"
:defaultOpen="'preview'"
:toolbarsFlag="false"
:scrollStyle="true"
:ishljs="true"
:navigation= "true"
@navigationToggle ="onAddUrl"
/>
js
watch: {
zuJianWD(){
this.onAddUrl()
}
},
methods:{
onAddUrl(){
this.$nextTick(function () {
let _aList = document.querySelectorAll(".v-note-navigation-content a");
for (let i = 0; i < _aList.length; i++) {
let _aParent = _aList[i].parentNode;
let _a = _aParent.firstChild;
if (!_a.id) continue; // 把不属于导航中的a标签去掉,否则会报错
let _text = _aParent.lastChild;
let text = _text.textContent;
_a.href = "#" + _a.id;
_a.innerText = text;
_aParent.removeChild(_text);
// _a.style.color = "red";
}
});
}