-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
/
Copy pathindex.vue
41 lines (39 loc) · 984 Bytes
/
index.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<template>
<div>
<editor ref="toastuiEditor" :options="editorOptions" height="500px" @load="onEditorLoad" @change="onEditorChange" />
</div>
</template>
<script>
import '@toast-ui/editor/dist/toastui-editor.css'
import { Editor } from '@toast-ui/vue-editor'
export default {
components: {
editor: Editor
},
data() {
return {
editorText: '',
editorOptions: {
hideModeSwitch: true
}
}
},
mounted() {
console.log(this.$route.query.editorText)
},
beforeDestroy() {
},
methods: {
onEditorLoad(editor) {
editor.setMarkdown(this.$route.query.editorText, true)
},
onEditorChange() {
const query = JSON.parse(JSON.stringify(this.$route.query)) // 获取路由参数信息
this.$nextTick(() => {
query.editorText = this.$refs.toastuiEditor.invoke('getMarkdown') // 改变参数
this.$router.push({ path: this.$route.path, query }) // 更新路由
})
}
}
}
</script>