| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- Vue.component('vue-easymde', VueEasyMDE.VueEasyMDE)
- // 查看消息需要用到的JS
- app = new Vue({
- el: '#app',
- data: {
- status: -1,
- text: null,
- easyMDEOpts: {
- toolbar: ['preview'],
- renderingConfig: { codeSyntaxHighlighting: true },
- },
- },
- mounted: function() {
- // 从URL获取GUID,然后透过POST获取消息
- var guid = reg_guid.exec(window.location.href)[0];
- axios.post('/api/get-msg', {
- guid: guid
- }).then(function (response) {
- var data = response.data;
- app.status = data.status;
- app.text = data.text;
- }).catch(function (error) {
- throw error;
- alert('发生错误!')
- });
- },
- watch: {
- status: function(status) {
- if (status !== 1) return;
- // 获取成功,等待装载并设定编辑器状态
- this.$nextTick(() => {
- var easyMDE = this.$refs.preview.getMDEInstance();
- easyMDE.togglePreview();
- easyMDE.codemirror.setOption('readOnly', true);
- });
- }
- }
- })
|