index.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <view>
  3. <mp-html container-style="padding:20px" :content="html" domain="https://mp-html.oss-cn-hangzhou.aliyuncs.com" lazy-load scroll-table selectable use-anchor :tag-style="tagStyle" @load="load" @ready="ready" @imgtap="imgtap" @linktap="linktap" />
  4. </view>
  5. </template>
  6. <script>
  7. // 需要测试 nvue 时,将本文件后缀改为 .nvue 即可
  8. // 注意:此示例不包含编辑功能
  9. import mpHtml from '@/components/mp-html/mp-html'
  10. import html from '../../content'
  11. export default {
  12. // HBuilderX 2.5.5+ 可以通过 easycom 自动引入
  13. components: {
  14. mpHtml
  15. },
  16. data () {
  17. return {
  18. html: '',
  19. tagStyle: {
  20. table: 'box-sizing: border-box; border-top: 1px solid #dfe2e5; border-left: 1px solid #dfe2e5;',
  21. th: 'border-right: 1px solid #dfe2e5; border-bottom: 1px solid #dfe2e5;',
  22. td: 'border-right: 1px solid #dfe2e5; border-bottom: 1px solid #dfe2e5;',
  23. li: 'margin: 5px 0;'
  24. }
  25. }
  26. },
  27. onLoad () {
  28. // 模拟网络请求
  29. setTimeout(() => {
  30. this.html = html
  31. }, 200)
  32. },
  33. methods: {
  34. load () {
  35. console.log('dom 树加载完毕')
  36. },
  37. ready (e) {
  38. console.log('ready 事件触发:', e)
  39. },
  40. imgtap (e) {
  41. console.log('imgtap 事件触发:', e)
  42. },
  43. linktap (e) {
  44. console.log('linktap 事件触发:', e)
  45. }
  46. }
  47. }
  48. </script>
  49. <style>
  50. </style>