component.nvue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. import uLink from '@/components/uLink.vue'
  35. export default {
  36. components: {
  37. uLink
  38. },
  39. data() {
  40. return {
  41. list: [{
  42. id: 'view',
  43. name: '视图容器',
  44. open: false,
  45. pages: [
  46. 'view',
  47. 'scroll-view',
  48. 'swiper'
  49. // #ifndef MP-TOUTIAO
  50. ,
  51. 'movable-view',
  52. 'cover-view'
  53. // #endif
  54. ]
  55. }, {
  56. id: 'content',
  57. name: '基础内容',
  58. open: false,
  59. pages: ['text', 'rich-text', 'progress']
  60. }, {
  61. id: 'form',
  62. name: '表单组件',
  63. open: false,
  64. pages: ['button', 'checkbox', 'form', 'input', 'label', 'picker', 'picker-view', 'radio',
  65. 'slider',
  66. 'switch', 'textarea',
  67. // #ifdef APP-PLUS || MP-WEIXIN || H5
  68. 'editor',
  69. // #endif
  70. ]
  71. }, {
  72. id: 'nav',
  73. name: '导航',
  74. open: false,
  75. pages: ['navigator']
  76. }, {
  77. id: 'media',
  78. name: '媒体组件',
  79. open: false,
  80. pages: [
  81. 'image',
  82. 'video',
  83. // #ifndef MP-ALIPAY || MP-TOUTIAO
  84. 'audio',
  85. // #endif
  86. ],
  87. },
  88. // #ifndef MP-TOUTIAO
  89. {
  90. id: 'map',
  91. name: '地图',
  92. open: false,
  93. pages: ['map']
  94. },
  95. // #endif
  96. // #ifndef QUICKAPP-WEBVIEW-UNION
  97. {
  98. id: 'canvas',
  99. name: '画布',
  100. open: false,
  101. pages: ['canvas']
  102. },
  103. // #endif
  104. // #ifdef APP-PLUS || H5
  105. {
  106. id: 'web-view',
  107. name: '网页',
  108. open: false,
  109. pages: [{
  110. name: '网络网页',
  111. url: '/pages/component/web-view/web-view'
  112. }, {
  113. name: '本地网页',
  114. url: '/pages/component/web-view-local/web-view-local'
  115. }]
  116. },
  117. // #endif
  118. // #ifndef APP-PLUS || H5
  119. {
  120. id: 'web-view',
  121. name: '网页',
  122. open: false,
  123. pages: ['web-view']
  124. },
  125. // #endif
  126. // #ifndef H5 || MP-BAIDU || QUICKAPP-WEBVIEW
  127. {
  128. url: 'ad',
  129. name: 'AD组件',
  130. open: false
  131. },
  132. // #endif
  133. ],
  134. navigateFlag: false
  135. }
  136. },
  137. onShareAppMessage() {
  138. return {
  139. title: '欢迎体验uni-app',
  140. path: '/pages/tabBar/component/component'
  141. }
  142. },
  143. onNavigationBarButtonTap(e) {
  144. uni.navigateTo({
  145. url: '/pages/about/about'
  146. });
  147. },
  148. methods: {
  149. triggerCollapse(e) {
  150. if (!this.list[e].pages) {
  151. this.goDetailPage(this.list[e].url);
  152. return;
  153. }
  154. for (var i = 0; i < this.list.length; ++i) {
  155. if (e === i) {
  156. this.list[i].open = !this.list[e].open;
  157. } else {
  158. this.list[i].open = false;
  159. }
  160. }
  161. },
  162. goDetailPage(e) {
  163. if (this.navigateFlag) {
  164. return;
  165. }
  166. this.navigateFlag = true;
  167. if (typeof e === 'string') {
  168. uni.navigateTo({
  169. url: '/pages/component/' + e + '/' + e
  170. })
  171. } else {
  172. uni.navigateTo({
  173. url: e.url
  174. })
  175. }
  176. setTimeout(() => {
  177. this.navigateFlag = false;
  178. }, 200)
  179. }
  180. }
  181. }
  182. </script>
  183. <style>
  184. @import '../../../common/uni-nvue.css';
  185. </style>