Merge pull request #87 from nagisa77/codex/fix-editor-not-refreshing-content

This commit is contained in:
Tim
2025-07-06 11:02:01 +08:00
committed by GitHub
2 changed files with 13 additions and 2 deletions

View File

@@ -5,7 +5,7 @@
</template>
<script>
import { ref, onMounted } from 'vue'
import { ref, onMounted, watch } from 'vue'
import Vditor from 'vditor'
import 'vditor/dist/index.css'
@@ -25,6 +25,15 @@ export default {
setup(props, { emit }) {
const vditorInstance = ref(null)
watch(
() => props.modelValue,
val => {
if (vditorInstance.value && vditorInstance.value.getValue() !== val) {
vditorInstance.value.setValue(val)
}
}
)
onMounted(() => {
vditorInstance.value = new Vditor(props.editorId, {
placeholder: '请输入正文...',

View File

@@ -61,7 +61,9 @@ export default {
toast.success('草稿已加载')
}
} catch (e) {}
} catch (e) {
console.error(e)
}
}
onMounted(loadDraft)