API.uvue 3.4 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2
<template>
  <!-- #ifdef APP -->
3
  <scroll-view style="flex: 1; background-color: #f8f8f8" enable-back-to-top="true">
DCloud-WZF's avatar
DCloud-WZF 已提交
4 5 6 7 8 9 10 11 12 13
  <!-- #endif -->
    <view class="uni-container">
      <view class="uni-header-logo">
        <image class="uni-header-image" src="/static/apiIndex.png"></image>
      </view>
      <view class="uni-text-box">
        <text class="hello-text">以下将演示uni-app接口能力,详细文档见:</text>
        <u-link :href="'https://uniapp.dcloud.io/uni-app-x/api/'" :text="'https://uniapp.dcloud.io/uni-app-x/api/'"
          :inWhiteList="true"></u-link>
      </view>
14 15 16
     <uni-collapse>
       <uni-collapse-item v-for="menuItem in menu" :key="menuItem!.id" :title="menuItem!.name"
         class="item">
17 18
         <view v-for="page in menuItem!.pages" :key="page!.path" class="uni-navigate-item" hover-class="is--active"
           @click="goPage(`/${page!.path}`)">
19
           <text class="uni-navigate-text">{{
20
               page!.style["navigationBarTitleText"]
21 22 23 24 25 26
             }}</text>
           <image :src="arrowRightIcon" class="uni-icon-size"></image>
         </view>
         <uni-collapse style="width: 100%" v-for="childMenu in menuItem!.children" :key="childMenu!.id">
           <uni-collapse-item :title="childMenu!.name" class="item" style="margin-bottom: 0">
             <view class="uni-navigate-item" hover-class="is--active" v-for="childPage in childMenu!.pages"
27
               :key="childPage!.path" @click="goPage(`/${childPage!.path}`)">
28
               <text class="uni-navigate-text">{{
29
                   childPage!.style["navigationBarTitleText"]
30 31 32 33 34 35 36
                 }}</text>
               <image :src="arrowRightIcon" class="uni-icon-size"></image>
             </view>
           </uni-collapse-item>
         </uni-collapse>
       </uni-collapse-item>
     </uni-collapse>
DCloud-WZF's avatar
DCloud-WZF 已提交
37 38 39 40 41 42 43 44 45 46 47 48
    </view>
  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
  <view ref="pop" @click="hidePop()" class="popup">
    <view style="width: 90%; background-color: white" @click="stopClickPop">
      <api-set-tabbar></api-set-tabbar>
    </view>
  </view>
</template>

<script lang="uts">
49 50 51
  import { generateMenu } from './generateMenu.uts'
  import { MenuItem } from './generateMenu.uts'
  const menu = generateMenu('pages/API')
DCloud-WZF's avatar
DCloud-WZF 已提交
52 53 54
  export default {
    data() {
      return {
55
        menu: menu as (MenuItem | null)[],
DCloud-WZF's avatar
DCloud-WZF 已提交
56 57 58 59
        arrowRightIcon: '/static/icons/arrow-right.png',
      }
    },
    methods: {
60
      goPage(url : string) {
61 62 63 64 65
        if (url == '/set-tab-bar') {
          this.showPop()
        } else {
          uni.navigateTo({ url })
        }
66
      },
DCloud-WZF's avatar
DCloud-WZF 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
      showPop: function () {
        (this.$refs["pop"] as UniElement).style.setProperty("display", "flex")
      },
      hidePop: function () {
        (this.$refs["pop"] as UniElement).style.setProperty("display", "none")
      },
      stopClickPop: function (e : PointerEvent) {
        e.stopPropagation() //点击到pop的非灰色区域,拦截点击事件
      }
    },
  }
</script>

<style>
  .item {
    margin-bottom: 12px;
  }

  .popup {
    width: 100%;
    /* #ifdef APP */
    position: absolute;
    height: 100%;
    /* #endif */
    /* #ifndef APP */
    position: fixed;
    top: var(--window-top);
    bottom: var(--window-bottom);
    /* #endif */
    align-items: center;
    justify-content: center;
    display: none;
    background-color: rgba(16, 16, 16, 0.5);
  }
101
</style>