index.vue 953 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <view>
  3. <!-- components/agent-ui/markdownPreview/index.wxml -->
  4. <towxml :nodes="text"></towxml>
  5. </view>
  6. </template>
  7. <script>
  8. import towxml from '@/components/agent-ui/markdownPreview/towxml/towxml';
  9. // components/agent-ui/markdownPreview/index.js
  10. import { markdownToWxml } from './utils';
  11. export default {
  12. components: {
  13. towxml
  14. },
  15. data() {
  16. return {
  17. text: {}
  18. };
  19. },
  20. /**
  21. * 组件的属性列表
  22. */
  23. props: {
  24. markdown: {
  25. type: String,
  26. default: ''
  27. }
  28. },
  29. watch: {
  30. markdown: function (value) {
  31. const wxml = markdownToWxml(value);
  32. this.setData({
  33. text: wxml
  34. });
  35. }
  36. },
  37. /**
  38. * 组件的方法列表
  39. */
  40. methods: {},
  41. created: function () {}
  42. };
  43. </script>
  44. <style>
  45. /* components/agent-ui/markdownPreview/index.wxss */
  46. </style>