Skip to content

Commit

Permalink
🐛 fix setValue throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
nicejade committed Aug 14, 2020
1 parent 2887fc4 commit 3cbee28
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/assets/styles/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ body {
}
}

#j-preview-vditor {
#khaleesi {
text-align: left;
}
18 changes: 9 additions & 9 deletions src/components/PreviewVditor.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="preview-vditor" v-loading="isLoading" element-loading-text="正在努力,请稍候...">
<div id="j-preview-vditor" class="vditor-preview" />
<div id="khaleesi" class="vditor-preview" />
</div>
</template>

Expand All @@ -26,6 +26,7 @@ export default {
created() {
this.$utils.updateHtmlStyle()
this.setDefaultText()
},
components: {},
Expand All @@ -45,15 +46,14 @@ export default {
show: true
}
}
this.vditor = new Vditor('j-preview-vditor', options)
try {
this.vditor.setValue(this.pdata)
} catch (err) {
console.log(`Something Error: `, err)
}
this.vditor = new Vditor('khaleesi', options)
this.$nextTick(() => {
this.isLoading = false
})
},
setDefaultText() {
localStorage.setItem('vditorkhaleesi', this.pdata)
}
}
}
Expand All @@ -68,7 +68,7 @@ export default {
min-height: 100vh;
background-color: @white;
.flex-box-center(column);
#j-preview-vditor {
#khaleesi {
max-width: 960px;
height: 100%;
min-height: 100vh;
Expand Down Expand Up @@ -102,7 +102,7 @@ export default {
@media (max-width: 768px) {
.preview-vditor {
#j-preview-vditor {
#khaleesi {
width: 100% !important;
margin: 0 !important;
}
Expand Down
2 changes: 1 addition & 1 deletion src/helper/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default {
},

hideVditorTextarea() {
const exportVditorNode = document.getElementById('j-preview-vditor')
const exportVditorNode = document.getElementById('khaleesi')
const option = {
childList: true, // 子节点的变动(新增、删除或者更改)
attributes: true, // 属性的变动
Expand Down

0 comments on commit 3cbee28

Please sign in to comment.