You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

89 lines
2.4 KiB

  1. <template>
  2. <!--判断是否是标签节点-->
  3. <block v-if="node.node == 'element'">
  4. <!--button类型-->
  5. <button v-if="node.tag == 'button'" type="default" size="mini" :class="node.classStr" :style="node.styleStr">
  6. <wx-parse-template :node="node" />
  7. </button>
  8. <!--a类型-->
  9. <view v-else-if="node.tag == 'a'" @click="wxParseATap(node.attr,$event)" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr">
  10. <block v-for="(node, index) of node.nodes" :key="index">
  11. <wx-parse-template :node="node" />
  12. </block>
  13. </view>
  14. <!--li类型-->
  15. <view v-else-if="node.tag == 'li'" :class="node.classStr" :style="node.styleStr">
  16. <block v-for="(node, index) of node.nodes" :key="index">
  17. <wx-parse-template :node="node" />
  18. </block>
  19. </view>
  20. <!--table类型-->
  21. <wx-parse-table v-else-if="node.tag == 'table'" :class="node.classStr" :style="node.styleStr" :node="node" />
  22. <!--br类型-->
  23. <!-- #ifndef H5 -->
  24. <text v-else-if="node.tag == 'br'">\n</text>
  25. <!-- #endif -->
  26. <!-- #ifdef H5 -->
  27. <br v-else-if="node.tag == 'br'">
  28. <!-- #endif -->
  29. <!--video类型-->
  30. <wx-parse-video :node="node" v-else-if="node.tag == 'video'"/>
  31. <!--audio类型-->
  32. <wx-parse-audio :node="node" v-else-if="node.tag == 'audio'"/>
  33. <!--img类型-->
  34. <wx-parse-img :node="node" v-else-if="node.tag == 'img'" :style="node.styleStr"/>
  35. <!--其他标签-->
  36. <view v-else :class="node.classStr" :style="node.styleStr">
  37. <block v-for="(node, index) of node.nodes" :key="index">
  38. <wx-parse-template :node="node" />
  39. </block>
  40. </view>
  41. </block>
  42. <!--判断是否是文本节点-->
  43. <block v-else-if="node.node == 'text' ">{{node.text}}</block>
  44. </template>
  45. <script>
  46. import wxParseTemplate from './wxParseTemplate4';
  47. import wxParseImg from './wxParseImg';
  48. import wxParseVideo from './wxParseVideo';
  49. import wxParseAudio from './wxParseAudio';
  50. import wxParseTable from './wxParseTable';
  51. export default {
  52. name: 'wxParseTemplate3',
  53. props: {
  54. node: {},
  55. },
  56. components: {
  57. wxParseTemplate,
  58. wxParseImg,
  59. wxParseVideo,
  60. wxParseAudio,
  61. wxParseTable
  62. },
  63. methods: {
  64. wxParseATap(attr,e) {
  65. const {
  66. href
  67. } = e.currentTarget.dataset;
  68. if (!href) return;
  69. let parent = this.$parent;
  70. while(!parent.preview || typeof parent.preview !== 'function') {
  71. parent = parent.$parent;
  72. }
  73. parent.navigate(href, e, attr);
  74. }
  75. }
  76. };
  77. </script>