rich-text-complex.uvue 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <!-- #ifdef APP -->
  3. <scroll-view style="flex: 1;">
  4. <!-- #endif -->
  5. <view>
  6. <page-head title="rich-text-complex"></page-head>
  7. <!-- #ifdef APP-ANDROID -->
  8. <enum-data title="设置mode(仅Android平台支持,默认值为web)" :items="modeItemTypes" @change="onModeChange"></enum-data>
  9. <!-- #endif -->
  10. <view class="uni-padding-wrap uni-common-mt" @click="fViewClick('触发父 view click 事件')">
  11. <rich-text :nodes="htmlString" :selectable="true" @itemclick="itemClick" @click="selfClick('触发 richtext click 事件')" :mode="mode"></rich-text>
  12. </view>
  13. </view>
  14. <!-- #ifdef APP -->
  15. </scroll-view>
  16. <!-- #endif -->
  17. </template>
  18. <script>
  19. import { ItemType } from '@/components/enum-data/enum-data-types';
  20. export default {
  21. data() {
  22. return {
  23. imageClicked: false,
  24. fViewClicked: false,
  25. selfClicked: false,
  26. htmlString: '<p><a href="https://www.dcloud.io/hbuilderx.html">HBuilderX</a><br/><img src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png"></img><h1>HBuilderX,轻巧、极速,极客编辑器</h1><p style="color:red;"><small>HBuilderX,轻巧、极速,极客编辑器 </small><big>HBuilderX,轻巧、极速,极客编辑器</big><strong>HBuilderX,轻巧、极速,极客编辑器</strong><i>HBuilderX,轻巧、极速,极客编辑器 </i><u>HBuilderX,轻巧、极速,极客编辑器</u><del>HBuilderX,轻巧、极速,极客编辑器</del></p><h2>uni-app x,终极跨平台方案</h2>、<p style="background-color: yellow;"><small>uni-app x,终极跨平台方案 </small><big>uni-app x,终极跨平台方案</big><strong>uni-appx,终极跨平台方案 </strong><i>uni-app x,终极跨平台方案 </i><u>uni-app x,终极跨平台方案 </u><del>uni-appx,终极跨平台方案</del></p><h3>uniCloud,js serverless云服务</h3><p style="text-decoration: line-through;"><small>uniCloud,js serverless云服务 </small><big>uniCloud,jsserverless云服务</big><strong>uniCloud,js serverless云服务 </strong><i>uniCloud,js serverless云服务 </i><u>uniCloud,jsserverless云服务</u><del>uniCloud,js serverless云服务</del></p><h4>uts,大一统语言</h4><p style="text-align: center;"><small>uts,大一统语言 </small><big>uts,大一统语言 </big><strong>uts,大一统语言</strong><i>uts,大一统语言</i><u>uts,大一统语言 </u><del>uts,大一统语言</del></p><h5>uniMPSdk,让你的App具备小程序能力</h5><h6>uni-admin,开源、现成的全端管理后台</h6><ul><li style="color: red; text-align: left;">uni-app x,终极跨平台方案</li><li style="color: green; text-align: center;">uni-app x,终极跨平台方案</li><li style="color: blue; text-align: right;">uni-app x,终极跨平台方案</li></ul><a href="https://uniapp.dcloud.net.cn">uni-app</a><br/><img src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png"></img></p>',
  27. mode: 'web',
  28. modeItems: ['web', 'native'],
  29. modeItemTypes: [{ 'value': 0, 'name': 'web' }, { 'value': 1, 'name': 'native' }] as ItemType[]
  30. }
  31. },
  32. methods: {
  33. itemClick(e : UniRichTextItemClickEvent) {
  34. console.log(JSON.stringify(e.detail));
  35. let clicktext = '';
  36. if (e.detail.src != null) {
  37. clicktext = '点击了图片,src = ' + e.detail.src;
  38. this.imageClicked = true
  39. } else if (e.detail.href != null) {
  40. clicktext = '点击了链接,href = ' + e.detail.href;
  41. }
  42. uni.showModal({
  43. content: clicktext,
  44. showCancel: false
  45. });
  46. },
  47. fViewClick(e : string) {
  48. console.log(e)
  49. this.fViewClicked = true
  50. },
  51. selfClick(e : string) {
  52. console.log(e)
  53. this.selfClicked = true
  54. },
  55. onModeChange: function (value : number) {
  56. this.mode = this.modeItems[value];
  57. }
  58. }
  59. }
  60. </script>