component.nvue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="uni-container">
  3. <view class="uni-header-logo">
  4. <image class="uni-header-image" src="/static/componentIndex.png"></image>
  5. </view>
  6. <view class="uni-hello-text">
  7. <text class="hello-text">uni-app内置组件,展示样式仅供参考,文档详见:</text>
  8. <u-link class="hello-link" :href="'https://uniapp.dcloud.io/component/'" :text="'https://uniapp.dcloud.io/component/'"
  9. :inWhiteList="true"></u-link>
  10. </view>
  11. <view class="uni-panel" v-for="(item, index) in list" :key="item.id">
  12. <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index)">
  13. <text class="uni-panel-text">{{item.name}}</text>
  14. <text class="uni-panel-icon uni-icon" :class="item.open ? 'uni-panel-icon-on' : ''">{{item.pages ? '&#xe581;' : '&#xe470;'}}</text>
  15. </view>
  16. <view class="uni-panel-c" v-if="item.open">
  17. <view class="uni-navigate-item" v-for="(item2,key) in item.pages" :key="key" @click="goDetailPage(item2)">
  18. <text class="uni-navigate-text">{{item2.name ? item2.name : item2}}</text>
  19. <text class="uni-navigate-icon uni-icon">&#xe470;</text>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. // TODO 修复Android v3 加载过慢问题
  27. // #ifdef APP-PLUS
  28. var domModule = weex.requireModule('dom');
  29. domModule.addRule('fontFace', {
  30. 'fontFamily': "uniicons",
  31. 'src': "url('/static/uni.ttf')"
  32. });
  33. // #endif
  34. export default {
  35. data() {
  36. return {
  37. list: [{
  38. id: 'view',
  39. name: '视图容器',
  40. open: false,
  41. pages: [
  42. 'view',
  43. 'scroll-view',
  44. 'swiper'
  45. // #ifndef MP-TOUTIAO
  46. ,
  47. 'movable-view',
  48. 'cover-view'
  49. // #endif
  50. ]
  51. }, {
  52. id: 'content',
  53. name: '基础内容',
  54. open: false,
  55. pages: ['text', 'rich-text', 'progress']
  56. }, {
  57. id: 'form',
  58. name: '表单组件',
  59. open: false,
  60. pages: ['button', 'checkbox', 'form', 'input', 'label', 'picker', 'picker-view', 'radio',
  61. 'slider',
  62. 'switch', 'textarea',
  63. // #ifdef APP-PLUS || MP-WEIXIN || H5
  64. 'editor',
  65. // #endif
  66. ]
  67. }, {
  68. id: 'nav',
  69. name: '导航',
  70. open: false,
  71. pages: ['navigator']
  72. }, {
  73. id: 'media',
  74. name: '媒体组件',
  75. open: false,
  76. pages: [
  77. 'image',
  78. 'video',
  79. // #ifndef MP-ALIPAY || MP-TOUTIAO
  80. 'audio',
  81. // #endif
  82. ],
  83. },
  84. // #ifndef MP-TOUTIAO
  85. {
  86. id: 'map',
  87. name: '地图',
  88. open: false,
  89. pages: ['map']
  90. },
  91. // #endif
  92. // #ifndef QUICKAPP-WEBVIEW-UNION
  93. {
  94. id: 'canvas',
  95. name: '画布',
  96. open: false,
  97. pages: ['canvas']
  98. },
  99. // #endif
  100. // #ifdef APP-PLUS || H5
  101. {
  102. id: 'web-view',
  103. name: '网页',
  104. open: false,
  105. pages: [{
  106. name: '网络网页',
  107. url: '/pages/component/web-view/web-view'
  108. }, {
  109. name: '本地网页',
  110. url: '/pages/component/web-view-local/web-view-local'
  111. }]
  112. },
  113. // #endif
  114. // #ifndef APP-PLUS || H5
  115. {
  116. id: 'web-view',
  117. name: '网页',
  118. open: false,
  119. pages: ['web-view']
  120. },
  121. // #endif
  122. // #ifndef H5 || MP-BAIDU || QUICKAPP-WEBVIEW
  123. {
  124. url: 'ad',
  125. name: 'AD组件',
  126. open: false
  127. },
  128. // #endif
  129. ]
  130. }
  131. },
  132. onShareAppMessage() {
  133. return {
  134. title: '欢迎体验uni-app',
  135. path: '/pages/tabBar/component/component'
  136. }
  137. },
  138. onNavigationBarButtonTap(e) {
  139. uni.navigateTo({
  140. url: '/pages/about/about'
  141. });
  142. },
  143. methods: {
  144. triggerCollapse(e) {
  145. if (!this.list[e].pages) {
  146. this.goDetailPage(this.list[e].url);
  147. return;
  148. }
  149. for (var i = 0; i < this.list.length; ++i) {
  150. if (e === i) {
  151. this.list[i].open = !this.list[e].open;
  152. } else {
  153. this.list[i].open = false;
  154. }
  155. }
  156. },
  157. goDetailPage(e) {
  158. if (typeof e === 'string') {
  159. uni.navigateTo({
  160. url: '/pages/component/' + e + '/' + e
  161. })
  162. } else {
  163. uni.navigateTo({
  164. url: e.url
  165. })
  166. }
  167. }
  168. }
  169. }
  170. </script>
  171. <style>
  172. @import '../../../common/uni-nvue.css';
  173. </style>