[Doc] Demo: use v-slot shorthand (#3574)

This commit is contained in:
neverland 2019-06-20 17:40:57 +08:00 committed by GitHub
parent d9f2ad6759
commit 5b12d80d97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 36 additions and 39 deletions

View File

@ -20,7 +20,7 @@
:title="$t('title')" :title="$t('title')"
:thumb="imageURL" :thumb="imageURL"
> >
<template v-slot:tags> <template #tags>
<div class="card__tags"> <div class="card__tags">
<van-tag <van-tag
plain plain
@ -37,7 +37,7 @@
</div> </div>
</template> </template>
<template v-slot:footer> <template #footer>
<div class="card__footer"> <div class="card__footer">
<van-button <van-button
round round

View File

@ -92,7 +92,7 @@
icon="shop-o" icon="shop-o"
is-link is-link
> >
<template v-slot:title> <template #title>
<span class="custom-text">{{ $t('cell') }}</span> <span class="custom-text">{{ $t('cell') }}</span>
<van-tag type="danger">{{ $t('tag') }}</van-tag> <van-tag type="danger">{{ $t('tag') }}</van-tag>
</template> </template>
@ -103,11 +103,12 @@
is-link is-link
/> />
<van-cell :title="$t('cell')"> <van-cell :title="$t('cell')">
<van-icon <template #right-icon>
v-slot:right-icon <van-icon
name="search" name="search"
class="custom-icon" class="custom-icon"
/> />
</template>
</van-cell> </van-cell>
</demo-block> </demo-block>
</demo-section> </demo-section>

View File

@ -99,9 +99,8 @@ exports[`renders demo correctly 1`] = `
<!----></i> <!----></i>
</div> </div>
<div class="van-cell"> <div class="van-cell">
<div class="van-cell__title"><span>单元格</span></div> <div class="van-cell__title"><span>单元格</span></div><i class="custom-icon van-icon van-icon-search">
<div class="van-cell__value"><i class="custom-icon van-icon van-icon-search"> <!----></i>
<!----></i></div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -31,7 +31,7 @@
<demo-block :title="$t('customIcon')"> <demo-block :title="$t('customIcon')">
<van-checkbox v-model="checkbox3"> <van-checkbox v-model="checkbox3">
{{ $t('customIcon') }} {{ $t('customIcon') }}
<template v-slot:icon="{ checked }"> <template #icon="{ checked }">
<img :src="checked ? icon.active : icon.inactive"> <img :src="checked ? icon.active : icon.inactive">
</template> </template>
</van-checkbox> </van-checkbox>

View File

@ -27,8 +27,8 @@
<demo-block :title="$t('titleSlot')"> <demo-block :title="$t('titleSlot')">
<van-collapse v-model="active3"> <van-collapse v-model="active3">
<van-collapse-item> <van-collapse-item>
<template v-slot:title> <template #title>
<div>{{ $t('title') + 1 }}<van-icon name="question-o" /></div> {{ $t('title') + 1 }}<van-icon name="question-o" />
</template> </template>
{{ $t('text') }} {{ $t('text') }}
</van-collapse-item> </van-collapse-item>

View File

@ -57,9 +57,8 @@ exports[`renders demo correctly 1`] = `
<div class="van-collapse-item"> <div class="van-collapse-item">
<div role="button" tabindex="0" aria-expanded="false" class="van-cell van-cell--clickable van-collapse-item__title"> <div role="button" tabindex="0" aria-expanded="false" class="van-cell van-cell--clickable van-collapse-item__title">
<div class="van-cell__title"> <div class="van-cell__title">
<div>标题1<i class="van-icon van-icon-question-o"> 标题1<i class="van-icon van-icon-question-o">
<!----></i></div> <!----></i></div><i class="van-icon van-icon-arrow van-cell__right-icon">
</div><i class="van-icon van-icon-arrow van-cell__right-icon">
<!----></i> <!----></i>
</div> </div>
</div> </div>

View File

@ -81,7 +81,7 @@
:label="$t('sms')" :label="$t('sms')"
:placeholder="$t('smsPlaceholder')" :placeholder="$t('smsPlaceholder')"
> >
<template v-slot:button> <template #button>
<van-button <van-button
size="small" size="small"
type="primary" type="primary"

View File

@ -39,7 +39,7 @@
:images="images" :images="images"
@change="onChange" @change="onChange"
> >
<template v-slot:index>{{ $t('index', index) }}</template> <template #index>{{ $t('index', index) }}</template>
</van-image-preview> </van-image-preview>
</demo-block> </demo-block>
</demo-section> </demo-section>

View File

@ -43,7 +43,7 @@
width="100%" width="100%"
height="27vw" height="27vw"
> >
<template v-slot:loading> <template #loading>
<van-loading <van-loading
type="spinner" type="spinner"
size="20" size="20"
@ -72,9 +72,7 @@
height="27vw" height="27vw"
src="x" src="x"
> >
<template v-slot:error> <template #error>{{ $t('loadFail') }}</template>
{{ $t('loadFail') }}
</template>
</van-image> </van-image>
<div class="text">{{ $t('customTip') }}</div> <div class="text">{{ $t('customTip') }}</div>
</van-col> </van-col>

View File

@ -17,7 +17,7 @@
:left-text="$t('back')" :left-text="$t('back')"
left-arrow left-arrow
> >
<template v-slot:right> <template #right>
<van-icon name="search" /> <van-icon name="search" />
</template> </template>
</van-nav-bar> </van-nav-bar>

View File

@ -17,7 +17,7 @@
:status="$t('status')" :status="$t('status')"
> >
<div>{{ $t('content') }}</div> <div>{{ $t('content') }}</div>
<template v-slot:footer> <template #footer>
<van-button size="small">{{ $t('button') }}</van-button> <van-button size="small">{{ $t('button') }}</van-button>
<van-button <van-button
size="small" size="small"

View File

@ -48,13 +48,13 @@
> >
<van-radio name="1"> <van-radio name="1">
{{ $t('radio') }} 1 {{ $t('radio') }} 1
<template v-slot:icon="{ checked }"> <template #icon="{ checked }">
<img :src="checked ? icon.active : icon.inactive"> <img :src="checked ? icon.active : icon.inactive">
</template> </template>
</van-radio> </van-radio>
<van-radio name="2"> <van-radio name="2">
{{ $t('radio') }} 2 {{ $t('radio') }} 2
<template v-slot:icon="{ checked }"> <template #icon="{ checked }">
<img :src="checked ? icon.active : icon.inactive"> <img :src="checked ? icon.active : icon.inactive">
</template> </template>
</van-radio> </van-radio>

View File

@ -28,7 +28,7 @@
:label="$t('label')" :label="$t('label')"
@search="onSearch" @search="onSearch"
> >
<template v-slot:action> <template #action>
<div @click="onSearch">{{ $t('search') }}</div> <div @click="onSearch">{{ $t('search') }}</div>
</template> </template>
</van-search> </van-search>

View File

@ -103,12 +103,12 @@
@buy-clicked="onBuyClicked" @buy-clicked="onBuyClicked"
@add-cart="onAddCartClicked" @add-cart="onAddCartClicked"
> >
<template v-slot:sku-header-price="{ price }"> <template #sku-header-price="{ price }">
<div class="van-sku__goods-price"> <div class="van-sku__goods-price">
<span class="van-sku__price-symbol"></span><span class="van-sku__price-num">{{ price }}</span> <span class="van-sku__price-symbol"></span><span class="van-sku__price-num">{{ price }}</span>
</div> </div>
</template> </template>
<template v-slot:sku-actions="{ skuEventBus }"> <template #sku-actions="{ skuEventBus }">
<div class="van-sku-actions"> <div class="van-sku-actions">
<van-button <van-button
square square

View File

@ -45,7 +45,7 @@
v-model="value6" v-model="value6"
active-color="#f44" active-color="#f44"
> >
<template v-slot:button> <template #button>
<div class="custom-button">{{ value6 }}</div> <div class="custom-button">{{ value6 }}</div>
</template> </template>
</van-slider> </van-slider>

View File

@ -35,7 +35,7 @@
@submit="onClickButton" @submit="onClickButton"
> >
<van-checkbox v-model="checked">{{ $t('check') }}</van-checkbox> <van-checkbox v-model="checked">{{ $t('check') }}</van-checkbox>
<template v-slot:tip> <template #tip>
{{ $t('tip2') }} {{ $t('tip2') }}
<span <span
class="edit-address" class="edit-address"

View File

@ -4,7 +4,7 @@
<van-notice-bar>{{ $t('tips') }}</van-notice-bar> <van-notice-bar>{{ $t('tips') }}</van-notice-bar>
<demo-block :title="$t('basicUsage')"> <demo-block :title="$t('basicUsage')">
<van-swipe-cell> <van-swipe-cell>
<template v-slot:left> <template #left>
<van-button <van-button
square square
type="danger" type="danger"
@ -16,7 +16,7 @@
:title="$t('title')" :title="$t('title')"
:value="$t('content')" :value="$t('content')"
/> />
<template v-slot:right> <template #right>
<van-button <van-button
square square
type="danger" type="danger"
@ -28,7 +28,7 @@
<demo-block :title="$t('title2')"> <demo-block :title="$t('title2')">
<van-swipe-cell :on-close="onClose"> <van-swipe-cell :on-close="onClose">
<template v-slot:left> <template #left>
<van-button <van-button
square square
type="danger" type="danger"
@ -40,7 +40,7 @@
:title="$t('title')" :title="$t('title')"
:value="$t('content')" :value="$t('content')"
/> />
<template v-slot:right> <template #right>
<van-button <van-button
square square
type="danger" type="danger"

View File

@ -70,7 +70,7 @@
<van-swipe-item>3</van-swipe-item> <van-swipe-item>3</van-swipe-item>
<van-swipe-item>4</van-swipe-item> <van-swipe-item>4</van-swipe-item>
<template v-slot:indicator> <template #indicator>
<div class="custom-indicator">{{ current + 1 }}/4</div> <div class="custom-indicator">{{ current + 1 }}/4</div>
</template> </template>
</van-swipe> </van-swipe>

View File

@ -82,7 +82,7 @@
v-for="index in 2" v-for="index in 2"
:key="index" :key="index"
> >
<template v-slot:title> <template #title>
<van-icon name="more-o" />{{ $t('tab') }} <van-icon name="more-o" />{{ $t('tab') }}
</template> </template>
{{ $t('content') }} {{ index }} {{ $t('content') }} {{ index }}

View File

@ -66,7 +66,7 @@
<van-tabbar v-model="active3"> <van-tabbar v-model="active3">
<van-tabbar-item info="3"> <van-tabbar-item info="3">
<span>{{ $t('custom') }}</span> <span>{{ $t('custom') }}</span>
<template v-slot:icon="{ active }"> <template #icon="{ active }">
<img :src="active ? icon.active : icon.normal"> <img :src="active ? icon.active : icon.normal">
</template> </template>
</van-tabbar-item> </van-tabbar-item>