fix: 文档无刷新的问题

This commit is contained in:
liulujian 2026-06-05 00:59:09 +08:00
parent 36843fb304
commit e724bc3326

View File

@ -26,6 +26,18 @@ export default {
await this.loadMarked();
this.fetchMdContent();
},
// router-view 使 keep-alive
// path query mounted
// $route.query.file
watch: {
'$route.query.file': {
handler(newFile, oldFile) {
if (newFile !== oldFile) {
this.fetchMdContent();
}
},
},
},
methods: {
loadMarked() {
return new Promise((resolve) => {
@ -53,6 +65,10 @@ export default {
});
},
fetchMdContent() {
// /
this.loading = true;
this.error = '';
this.content = '';
const { file } = this.$route.query;
if (!file) {
this.content = '# 未指定文件\n\n请使用 ?file=xxx 传递文件路径';