CSS.uvue 13.3 KB
Newer Older
M
mehaotian 已提交
1
<template>
W
wanganxp 已提交
2
  <!-- #ifdef APP -->
3
  <scroll-view style="flex: 1; background-color: #f8f8f8" enable-back-to-top="true">
4
  <!-- #endif -->
W
wanganxp 已提交
5 6 7 8
    <view class="uni-container">
      <view class="uni-header-logo">
        <image class="uni-header-image" src="/static/cssIndex.png"></image>
      </view>
Y
yurj26 已提交
9
      <view class="uni-text-box">
W
wanganxp 已提交
10
        <text class="hello-text">uni-app x目前已支持的CSS属性,展示样式仅供参考,文档详见:</text>
W
wanganxp 已提交
11
        <u-link :href="'https://uniapp.dcloud.io/uni-app-x/css/'" :text="'https://uniapp.dcloud.io/uni-app-x/css/'"
W
wanganxp 已提交
12 13 14 15 16
          :inWhiteList="true"></u-link>
      </view>
      <uni-collapse>
        <template v-for="item in list" :key="item.id">
          <uni-collapse-item :title="item.name" class="item">
17
            <view class="uni-navigate-item" :hover-class="page.enable == false ? '' : 'is--active'"
W
wanganxp 已提交
18 19 20
              v-for="(page, key) in item.pages" :key="key" @click="goDetailPage(page)">
              <text class="uni-navigate-text"
                :class="page.enable == false ? 'text-disabled' : ''">{{ page.name }}</text>
21
              <image :src="arrowRightIcon" class="uni-icon-size"></image>
W
wanganxp 已提交
22 23 24 25
            </view>
          </uni-collapse-item>
        </template>
      </uni-collapse>
26 27

      <text>---------------</text>
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
      <uni-collapse>
        <uni-collapse-item v-for="menuItem in menu" :key="menuItem!.id" :title="menuItem!.name"
          class="item">
          <view v-for="page in menuItem!.pages" :key="page.path" class="uni-navigate-item" hover-class="is--active"
            @click="goPage(`/${page.path}`)">
            <text class="uni-navigate-text">{{
                page.style["navigationBarTitleText"]
              }}</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"
                :key="childPage.path" @click="goPage(`/${childPage.path}`)">
                <text class="uni-navigate-text">{{
                    childPage.style["navigationBarTitleText"]
                  }}</text>
                <image :src="arrowRightIcon" class="uni-icon-size"></image>
              </view>
            </uni-collapse-item>
          </uni-collapse>
        </uni-collapse-item>
50
      </uni-collapse>
W
wanganxp 已提交
51
    </view>
52
  <!-- #ifdef APP -->
W
wanganxp 已提交
53 54
  </scroll-view>
  <!-- #endif -->
M
mehaotian 已提交
55 56
</template>

Y
yurj26 已提交
57
<script lang="uts">
58 59 60
  import { generateMenu } from './generateMenu.uts'
  import { MenuItem } from './generateMenu.uts'
  const menu = generateMenu('pages/CSS')
W
wanganxp 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
  type Page = {
    name : string
    enable ?: boolean
    url ?: string
  }
  type ListItem = {
    id : string
    name : string
    pages : Page[]
    url ?: string
    enable ?: boolean
  }
  export default {
    data() {
      return {
76
        menu: menu as (MenuItem | null)[],
W
wanganxp 已提交
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
        list: [
          {
            id: 'background',
            name: 'background',
            pages: [
              {
                name: 'background-color',
                url: '/pages/CSS/background/background-color',
              },
              {
                name: 'background-image',
                url: '/pages/CSS/background/background-image',
              },
            ] as Page[],
          },
          {
            id: 'border',
            name: 'border',
            pages: [
              {
                name: 'border',
                url: '/pages/CSS/border/border',
              },
              {
                name: 'border-width',
                url: '/pages/CSS/border/border-width',
              },
              {
                name: 'border-style',
                url: '/pages/CSS/border/border-style',
              },
              {
                name: 'border-color',
                url: '/pages/CSS/border/border-color',
              },
              {
                name: 'border-radius',
                url: '/pages/CSS/border/border-radius',
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
              },
              {
                name: 'border-top',
                url: '/pages/CSS/border/border-top',
              },
              {
                name: 'border-bottom',
                url: '/pages/CSS/border/border-bottom',
              },
              {
                name: 'border-left',
                url: '/pages/CSS/border/border-left',
              },
              {
                name: 'border-right',
                url: '/pages/CSS/border/border-right',
W
wanganxp 已提交
131 132 133 134
              },
              {
                name: 'border属性复合示例',
                url: '/pages/CSS/border/complex-border/complex-border',
135 136 137 138
              },
              {
                name: 'border动态修改样式',
                url: '/pages/CSS/border/dynamic-border'
W
wanganxp 已提交
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
              },
            ] as Page[],
          },
          {
            id: 'box-shadow',
            name: 'box-shadow',
            pages: [
              {
                name: 'box-shadow',
                url: '/pages/CSS/box-shadow/box-shadow',
              },
            ] as Page[],
          },
          {
            id: 'display',
            name: 'display',
            pages: [
              {
                name: 'flex',
                url: '/pages/CSS/display/flex',
              },
              {
                name: 'none',
                url: '/pages/CSS/display/none',
              }
            ] as Page[],
          },
          {
            id: 'flex',
            name: 'flex',
            pages: [
              {
                name: 'align-content',
                url: '/pages/CSS/flex/align-content',
              },
              {
                name: 'align-items',
                url: '/pages/CSS/flex/align-items',
              },
              {
                name: 'flex-basis',
                url: '/pages/CSS/flex/flex-basis',
              },
              {
                name: 'flex-direction',
                url: '/pages/CSS/flex/flex-direction',
              },
              {
                name: 'flex-flow',
                url: '/pages/CSS/flex/flex-flow',
              },
              {
                name: 'flex-grow',
                url: '/pages/CSS/flex/flex-grow',
              },
              {
                name: 'flex-shrink',
                url: '/pages/CSS/flex/flex-shrink',
              },
              {
                name: 'flex',
                url: '/pages/CSS/flex/flex',
              },
              {
                name: 'justify-content',
                url: '/pages/CSS/flex/justify-content',
              },
            ] as Page[],
          },
          {
            id: 'layout',
            name: 'layout',
            pages: [
              {
                name: 'height',
                url: '/pages/CSS/layout/height',
              },
              {
                name: 'max-height',
                url: '/pages/CSS/layout/max-height',
              },
              {
                name: 'max-width',
                url: '/pages/CSS/layout/max-width',
              },
              {
                name: 'min-height',
                url: '/pages/CSS/layout/min-height',
              },
              {
                name: 'min-width',
                url: '/pages/CSS/layout/min-width',
              },
              {
                name: 'position',
                url: '/pages/CSS/layout/position',
              },
              {
                name: 'width',
                url: '/pages/CSS/layout/width',
239 240 241 242
              },
              {
                name: 'z-index',
                url: '/pages/CSS/layout/z-index',
W
wanganxp 已提交
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
              },
              {
                name: 'visibility',
                url: '/pages/CSS/layout/visibility',
              },
            ] as Page[],
          },
          {
            id: 'margin',
            name: 'margin',
            pages: [
              {
                name: 'margin-bottom',
                url: '/pages/CSS/margin/margin-bottom',
              },
              {
                name: 'margin-left',
                url: '/pages/CSS/margin/margin-left',
              },
              {
                name: 'margin-right',
                url: '/pages/CSS/margin/margin-right',
              },
              {
                name: 'margin-top',
                url: '/pages/CSS/margin/margin-top',
              },
              {
                name: 'margin',
                url: '/pages/CSS/margin/margin',
              },
            ] as Page[],
          },
          {
            id: 'padding',
            name: 'padding',
            pages: [
              {
                name: 'padding-bottom',
                url: '/pages/CSS/padding/padding-bottom',
              },
              {
                name: 'padding-left',
                url: '/pages/CSS/padding/padding-left',
              },
              {
                name: 'padding-right',
                url: '/pages/CSS/padding/padding-right',
              },
              {
                name: 'padding-top',
                url: '/pages/CSS/padding/padding-top',
              },
              {
                name: 'padding',
                url: '/pages/CSS/padding/padding',
              },
            ] as Page[],
301 302 303 304 305 306 307 308
          },
          {
            id: 'overflow',
            name: 'overflow',
            pages: [
              {
                name: 'overflow',
                url: '/pages/CSS/overflow/overflow',
309 310 311 312
              },
              {
                name: 'overflow-visible-event',
                url: '/pages/CSS/overflow/overflow-visible-event'
313
              }
314
            ] as Page[],
W
wanganxp 已提交
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
          },
          {
            id: 'text',
            name: 'text',
            pages: [
              {
                name: 'color',
                url: '/pages/CSS/text/color',
              },
              {
                name: 'font-family',
                url: '/pages/CSS/text/font-family',
              },
              {
                name: 'font-size',
                url: '/pages/CSS/text/font-size',
              },
              {
                name: 'font-style',
                url: '/pages/CSS/text/font-style',
              },
              {
                name: 'font-weight',
                url: '/pages/CSS/text/font-weight',
              },
              {
                name: 'letter-spacing',
                url: '/pages/CSS/text/letter-spacing',
              },
              {
                name: 'line-height',
                url: '/pages/CSS/text/line-height',
              },
              {
                name: 'text-align',
                url: '/pages/CSS/text/text-align',
              },
              {
                name: 'text-overflow',
                url: '/pages/CSS/text/text-overflow',
              },
              {
                name: 'text-decoration-line',
                url: '/pages/CSS/text/text-decoration-line',
              },
            ] as Page[],
          },
          {
            id: 'transform',
            name: 'transform',
            pages: [
              {
                name: 'translate',
                url: '/pages/CSS/transform/translate',
              },
              {
                name: 'scale',
                url: '/pages/CSS/transform/scale',
              },
              {
                name: 'rotate',
                url: '/pages/CSS/transform/rotate',
              },
            ] as Page[],
          },
          {
            id: 'transition',
            name: 'transition',
            pages: [
              {
                name: 'transition',
                url: '/pages/CSS/transition/transition',
              },
            ] as Page[],
389 390 391 392 393 394 395 396 397 398
          },
          {
            id: 'pointer-events',
            name: 'pointer-events',
            pages: [
              {
                name: 'pointer-events',
                url: '/pages/CSS/pointer-events/pointer-events',
              },
            ] as Page[],
399 400 401 402 403 404 405 406 407 408
          },
          {
            id: 'variable',
            name: 'variable',
            pages: [
              {
                name: 'variable',
                url: '/pages/CSS/variable/variable',
              },
            ] as Page[],
W
wanganxp 已提交
409
          }
W
wanganxp 已提交
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
        ] as ListItem[],
        arrowUpIcon: '/static/icons/arrow-up.png',
        arrowDownIcon: '/static/icons/arrow-down.png',
        arrowRightIcon: '/static/icons/arrow-right.png',
      }
    },
    methods: {
      goDetailPage(e : Page) {
        if (e.enable == false) {
          uni.showToast({
            icon: 'none',
            title: '暂不支持',
          })
          return
        }
        const url = e.url != null ? e.url! : `/pages/CSS/${e.name}/${e.name}`
        uni.navigateTo({
          url,
        })
      },
430 431 432
      goPage(url : string) {
        uni.navigateTo({ url })
      },
W
wanganxp 已提交
433 434
    },
  }
M
mehaotian 已提交
435 436 437
</script>

<style>
W
wanganxp 已提交
438 439 440
  .item {
    margin-bottom: 12px;
  }
Y
yurj26 已提交
441
</style>