view.js 925 B

12345678910111213141516171819202122232425262728293031323334
  1. Vue.component('vue-easymde', VueEasyMDE.VueEasyMDE)
  2. // 查看消息需要用到的JS
  3. app = new Vue({
  4. el: '#app',
  5. data: {
  6. status: -1,
  7. text: null,
  8. },
  9. mounted: function() {
  10. // 从URL获取GUID,然后透过POST获取消息
  11. var guid = reg_guid.exec(window.location.href)[0];
  12. axios.post('/api/get-msg', {
  13. guid: guid
  14. }).then(function (response) {
  15. var data = response.data;
  16. app.status = data.status;
  17. app.text = data.text;
  18. }).catch(function (error) {
  19. throw error;
  20. alert('发生错误!')
  21. });
  22. },
  23. watch: {
  24. status(newVal) {
  25. if (newVal !== 1) return;
  26. // 获取成功,等待装载并设定编辑器状态
  27. this.$nextTick(() => {
  28. var easyMDE = this.$refs.preview.getMDEInstance();
  29. easyMDE.togglePreview();
  30. easyMDE.codemirror.setOption('readOnly', true);
  31. });
  32. },
  33. },
  34. });