Merge branch 'dev' of https://github.com/youzan/vant into dev

This commit is contained in:
陈嘉涵 2018-04-25 14:48:59 +08:00
commit 7714065a3e
107 changed files with 646 additions and 862 deletions

View File

@ -1,17 +1,16 @@
<template> <template>
<demo-section> <demo-section>
<demo-block :title="$t('basicUsage')"> <demo-block :title="$t('basicUsage')">
<van-checkbox v-model="checkbox1">{{ $t('checkbox') }} 1</van-checkbox> <van-checkbox v-model="checkbox1">{{ $t('checkbox') }}</van-checkbox>
</demo-block> </demo-block>
<demo-block :title="$t('disabled')"> <demo-block :title="$t('disabled')">
<van-checkbox :value="false" disabled>{{ $t('checkbox') }} 2</van-checkbox> <van-checkbox :value="false" disabled>{{ $t('checkbox') }}</van-checkbox>
<van-checkbox :value="true" disabled>{{ $t('checkbox') }} 2</van-checkbox> <van-checkbox :value="true" disabled>{{ $t('checkbox') }}</van-checkbox>
</demo-block> </demo-block>
<demo-block :title="$t('labelDisabled')"> <demo-block :title="$t('labelDisabled')">
<van-checkbox v-model="checkbox3" label-disabled>{{ $t('checkbox') }} 2</van-checkbox> <van-checkbox v-model="checkbox2" label-disabled>{{ $t('checkbox') }}</van-checkbox>
<van-checkbox v-model="checkbox4" label-disabled>{{ $t('checkbox') }} 2</van-checkbox>
</demo-block> </demo-block>
<demo-block :title="$t('title3')"> <demo-block :title="$t('title3')">
@ -27,20 +26,22 @@
</demo-block> </demo-block>
<demo-block :title="$t('title4')"> <demo-block :title="$t('title4')">
<van-checkbox-group v-model="result"> <van-checkbox-group v-model="result2" :max="2">
<van-cell-group> <van-checkbox
<van-cell v-for="(item, index) in list" :key="index"> v-for="(item, index) in list"
<van-checkbox :name="item">{{ $t('checkbox') }} {{ item }}</van-checkbox> :key="index"
</van-cell> :name="item"
</van-cell-group> >
{{ $t('checkbox') }} {{ item }}
</van-checkbox>
</van-checkbox-group> </van-checkbox-group>
</demo-block> </demo-block>
<demo-block :title="$t('title5')"> <demo-block :title="$t('title5')">
<van-checkbox-group v-model="result2" :max="max"> <van-checkbox-group v-model="result3">
<van-cell-group> <van-cell-group>
<van-cell v-for="(item, index) in list" :key="index"> <van-cell v-for="(item, index) in list" :title="$t('checkbox') + item" :key="index">
<van-checkbox :name="item">{{ $t('checkbox') }} {{ item }}</van-checkbox> <van-checkbox :name="item" />
</van-cell> </van-cell>
</van-cell-group> </van-cell-group>
</van-checkbox-group> </van-checkbox-group>
@ -53,17 +54,17 @@ export default {
i18n: { i18n: {
'zh-CN': { 'zh-CN': {
checkbox: '复选框', checkbox: '复选框',
labelDisabled: '禁用 Checkbox 内容部分点击事件', labelDisabled: '禁用内容部分点击事件',
title3: 'Checkbox 组', title3: 'Checkbox 组',
title4: '与 Cell 组件一起使用', title4: '设置最大可选数',
title5: '设置最大可选数', title5: '与 Cell 组件一起使用'
}, },
'en-US': { 'en-US': {
checkbox: 'Checkbox', checkbox: 'Checkbox',
labelDisabled: 'Disable Checkbox Label click event', labelDisabled: 'Disable Label click event',
title3: 'Checkbox Group', title3: 'Checkbox Group',
title4: 'Inside a Cell', title4: 'Maximum amount of checked options',
title5: 'Maximum amount of checked options' title5: 'Inside a Cell'
} }
}, },
@ -71,8 +72,6 @@ export default {
return { return {
checkbox1: true, checkbox1: true,
checkbox2: true, checkbox2: true,
checkbox3: false,
checkbox4: true,
list: [ list: [
'a', 'a',
'b', 'b',
@ -80,7 +79,7 @@ export default {
], ],
result: ['a', 'b'], result: ['a', 'b'],
result2: [], result2: [],
max: 2 result3: []
}; };
} }
}; };
@ -95,13 +94,6 @@ export default {
.van-cell { .van-cell {
.van-checkbox { .van-checkbox {
margin: 0; margin: 0;
display: flex;
flex-direction: row-reverse;
&__label {
margin: 0;
flex: 1;
}
} }
} }
} }

View File

@ -65,7 +65,7 @@ export default {
<style lang="postcss"> <style lang="postcss">
.demo-list { .demo-list {
.van-cell { .van-cell {
justify-content: center; text-align: center;
} }
.page-desc { .page-desc {

View File

@ -17,8 +17,12 @@
<demo-block :title="$t('title3')"> <demo-block :title="$t('title3')">
<van-radio-group v-model="radio3"> <van-radio-group v-model="radio3">
<van-cell-group> <van-cell-group>
<van-cell><van-radio name="1">{{ $t('radio') }}1</van-radio></van-cell> <van-cell :title="$t('radio') + 1" clickable @click="radio3 = '1'">
<van-cell><van-radio name="2">{{ $t('radio') }}2</van-radio></van-cell> <van-radio name="1" />
</van-cell>
<van-cell :title="$t('radio') + 2" clickable @click="radio3 = '2'">
<van-radio name="2" />
</van-cell>
</van-cell-group> </van-cell-group>
</van-radio-group> </van-radio-group>
</demo-block> </demo-block>
@ -61,16 +65,5 @@ export default {
margin-bottom: 10px; margin-bottom: 10px;
} }
} }
.van-cell {
.van-radio__input {
float: right;
position: static;
}
.van-radio__label {
margin: 0;
}
}
} }
</style> </style>

View File

@ -61,7 +61,7 @@
> >
<template slot="sku-header-price" slot-scope="props"> <template slot="sku-header-price" slot-scope="props">
<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">{{ props.price }}</span> only!!! <span class="van-sku__price-symbol"></span><span class="van-sku__price-num">{{ props.price }}</span>
</div> </div>
</template> </template>
<template slot="sku-actions" slot-scope="props"> <template slot="sku-actions" slot-scope="props">

View File

@ -1,19 +1,15 @@
<template> <template>
<demo-section> <demo-section>
<demo-block :title="$t('title1')"> <demo-block :title="$t('title1')">
<van-slider v-model="value1"/> <van-slider v-model="value1" @change="onChange" />
<van-row>
<van-col span="24">
<van-stepper v-model="value1" />
</van-col>
</van-row>
</demo-block> </demo-block>
<demo-block :title="$t('title2')"> <demo-block :title="$t('title2')">
<van-slider <van-slider
v-model="value2" v-model="value2"
:min="min" :min="10"
:max="max" :max="90"
@change="onChange"
/> />
</demo-block> </demo-block>
@ -24,17 +20,9 @@
<demo-block :title="$t('title4')"> <demo-block :title="$t('title4')">
<van-slider <van-slider
v-model="value4" v-model="value4"
@change="handleChange" :step="10"
@after-change="handleAfterChange" bar-height="4px"
/> @change="onChange"
</demo-block>
<demo-block :title="$t('title5')">
<van-slider
v-model="value5"
pivot-color="#333"
loaded-bar-color="red"
bar-color="blue"
/> />
</demo-block> </demo-block>
</demo-section> </demo-section>
@ -45,46 +33,43 @@ export default {
i18n: { i18n: {
'zh-CN': { 'zh-CN': {
title1: '基本用法', title1: '基本用法',
title2: '最大最小值', title2: '指定选择范围',
title3: '禁用', title3: '禁用',
title4: '事件', title4: '指定步长',
title5: '自定义样式' text: '当前值:'
}, },
'en-US': { 'en-US': {
title1: 'Basic Usage', title1: 'Basic Usage',
title2: 'Max && Min', title2: 'Range',
title3: 'Disabed', title3: 'Disabled',
title4: 'Event', title4: 'Step size',
title5: 'Customized style' text: 'Current value: '
} }
}, },
data() { data() {
return { return {
value1: 50, value1: 50,
value2: 50, value2: 50,
value3: 50, value3: 50,
value4: 50, value4: 50
value5: 50, };
min: 10,
max: 90
}
}, },
methods: { methods: {
handleChange(value) { onChange(value) {
console.log('handleChange:', value) this.$toast(this.$t('text') + value);
},
handleAfterChange(value) {
console.log('handleAfterChange:', value)
} }
} }
}; };
</script> </script>
<style lang="postcss"> <style lang="postcss">
.van-row { .demo-slider {
padding-top: 20px; user-select: none;
.van-col {
text-align: center; .van-slider {
margin: 0 15px 30px;
} }
} }
</style> </style>

View File

@ -12,7 +12,7 @@ Vue.use(Checkbox).use(CheckboxGroup);
#### Basic Usage #### Basic Usage
```html ```html
<van-checkbox v-model="checked">Checkbox 1</van-checkbox> <van-checkbox v-model="checked">Checkbox</van-checkbox>
``` ```
```javascript ```javascript
@ -28,7 +28,13 @@ export default {
#### Disabled #### Disabled
```html ```html
<van-checkbox v-model="checked" disabled>Checkbox 2</van-checkbox> <van-checkbox v-model="checked" disabled>Checkbox</van-checkbox>
```
#### Disable Label click event
```html
<van-checkbox v-model="checked" label-disabled>Checkbox</van-checkbox>
``` ```
#### Checkbox Group #### Checkbox Group
@ -76,8 +82,8 @@ export default {
```html ```html
<van-checkbox-group v-model="result"> <van-checkbox-group v-model="result">
<van-cell-group> <van-cell-group>
<van-cell v-for="(item, index) in list" :key="item"> <van-cell v-for="item in list" :title="`Checkbox ${item}`" :key="item">
<van-checkbox :name="item">Checkbox {{ item }}</van-checkbox> <van-checkbox :name="item" />
</van-cell> </van-cell>
</van-cell-group> </van-cell-group>
</van-checkbox-group> </van-checkbox-group>

View File

@ -68,3 +68,9 @@ Vue.use(Vant);
```shell ```shell
vue init youzan/vue-cli-template-vant projectName vue init youzan/vue-cli-template-vant projectName
``` ```
### rem units
Vant use `px` as size units by defaultyou can use tools such as `postcss-pxtorem` to transform units to `rem`.
- [postcss-pxtorem](https://github.com/cuth/postcss-pxtorem)
- [lib-flexible](https://github.com/amfe/lib-flexible)

View File

@ -44,8 +44,12 @@ export default {
```html ```html
<van-radio-group v-model="radio"> <van-radio-group v-model="radio">
<van-cell-group> <van-cell-group>
<van-cell><van-radio name="1">Radio 1</van-radio></van-cell> <van-cell :title="Radio 1" clickable @click="radio = '1'">
<van-cell><van-radio name="2">Radio 2</van-radio></van-cell> <van-radio name="1" />
</van-cell>
<van-cell :title="Radio 2" clickable @click="radio = '2'">
<van-radio name="2" />
</van-cell>
</van-cell-group> </van-cell-group>
</van-radio-group> </van-radio-group>
``` ```

View File

@ -67,7 +67,7 @@ Vue.use(Sku);
<!-- custom sku-header-price --> <!-- custom sku-header-price -->
<template slot="sku-header-price" slot-scope="props"> <template slot="sku-header-price" slot-scope="props">
<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">{{ props.price }}</span> only!!! <span class="van-sku__price-symbol"></span><span class="van-sku__price-num">{{ props.price }}</span>
</div> </div>
</template> </template>
<!-- custom sku actions --> <!-- custom sku actions -->

View File

@ -11,99 +11,56 @@ Vue.use(Slider);
#### Basic Usage #### Basic Usage
```html ```html
<van-slider v-model="value1"/> <van-slider v-model="value" @change="onChange" />
<van-row>
<van-col span="12">
<van-stepper v-model="value1" />
</van-col>
</van-row>
``` ```
```js ```js
export default {
data() { data() {
return { return {
value1: 50 value: 50
} };
}
```
#### Max && Min
```html
<van-slider
v-model="value2"
:min="min"
:max="max"
/>
```
```js
data() {
return {
value2: 50,
min: 10,
max: 90
}
}
```
#### Disabed
```html
<van-slider v-model="value3" disabled />
```
#### Customized style
```html
<van-slider
v-model="value4"
@change="handleChange"
@after-change="handleAfterChange"
/>
```
```js
data() {
return {
value4: 50
}
}, },
methods: { methods: {
handleChange(value) { onChange(value) {
console.log('handleChange:', value) this.$toast('Current value' + value);
},
handleAfterChange(value) {
console.log('handleAfterChange:', value)
} }
} }
};
``` ```
### Customized style #### Range
```html ```html
<van-slider <van-slider v-model="value" :min="10" :max="90" />
v-model="value5" ```
pivot-color="#333"
loaded-bar-color="red" #### Disabled
bar-color="blue"
/> ```html
<van-slider v-model="value" disabled />
```
#### Step size
```html
<van-slider v-model="value" :step="10" bar-height="4px" />
``` ```
### API ### API
| Attribute | Description | Type | Default | Accepted Values | | Attribute | Description | Type | Default |
|-----------|-----------|-----------|-------------|-------------| |-----------|-----------|-----------|-------------|-------------|
| value | current value | Number | 0 | - | | value | Current value | `Number` | `0` |
| disabled | disabled | Boolean | false | - | | disabled | Whether to disable slider | `Boolean` | `false` |
| bar-color | bar-color | string | `#cacaca` | - | | max | Max value | `Number` | `100` |
| loaded-bar-color | loaded-bar-color | string | `#4b0` | - | | min | Min value | `Number` | `0` |
| pivot-color | pivot-color | string | `#4b0` | - | | step | Step size | `Number` | `1` |
| max | max | Number | 100 | - | | bar-height | Height of bar | `String` | `2px` |
| min | min | Number | 0 | - |
### Event ### Event
| Event | Description | Arguments | | Event | Description | Arguments |
|-----------|-----------|-----------| |-----------|-----------|-----------|
| change | touchmove emit | value | | change | Triggered after value change | value: current rate |
| after-change | touchend emit | value |

View File

@ -43,6 +43,7 @@ You can set native properties such as `accpet`、`multiple` on Uploader, and the
| Attribute | Description | Type | Default | Accepted Values | | Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------| |-----------|-----------|-----------|-------------|-------------|
| result-type | Type of file read result | `String` | `dataUrl` | `text` | | result-type | Type of file read result | `String` | `dataUrl` | `text` |
| accept | Accepted file type | `String` | `image/*` | - |
| disabled | Whether to disabled the upload | `Boolean` | `false` | - | | disabled | Whether to disabled the upload | `Boolean` | `false` | - |
| before-read | Hook before reading the file, return false to stop reading the file | `Function` | - | - | | before-read | Hook before reading the file, return false to stop reading the file | `Function` | - | - |
| after-read | Hook after reading the file | `Function` | - | - | | after-read | Hook after reading the file | `Function` | - | - |

View File

@ -13,7 +13,7 @@ Vue.use(Checkbox).use(CheckboxGroup);
通过`v-model`绑定 checkbox 的勾选状态 通过`v-model`绑定 checkbox 的勾选状态
```html ```html
<van-checkbox v-model="checked">复选框 1</van-checkbox> <van-checkbox v-model="checked">复选框</van-checkbox>
``` ```
```javascript ```javascript
@ -29,13 +29,15 @@ export default {
#### 禁用状态 #### 禁用状态
```html ```html
<van-checkbox v-model="checked" disabled>复选框 2</van-checkbox> <van-checkbox v-model="checked" disabled>复选框</van-checkbox>
``` ```
#### 禁用内容部分点击事件 #### 禁用内容部分点击事件
```html ```html
<van-checkbox v-model="checked" label-disabled>复选框 3</van-checkbox> <van-checkbox v-model="checked" label-disabled>复选框</van-checkbox>
``` ```
#### Checkbox 组 #### Checkbox 组
需要与`van-checkbox-group`一起使用,选中值是一个数组,通过`v-model`绑定在`van-checkbox-group`上,数组中的项即为选中的`Checkbox``name`属性设置的值 需要与`van-checkbox-group`一起使用,选中值是一个数组,通过`v-model`绑定在`van-checkbox-group`上,数组中的项即为选中的`Checkbox``name`属性设置的值
@ -84,8 +86,8 @@ export default {
```html ```html
<van-checkbox-group v-model="result"> <van-checkbox-group v-model="result">
<van-cell-group> <van-cell-group>
<van-cell v-for="(item, index) in list" :key="item"> <van-cell v-for="item in list" :title="`复选框 ${item}`" :key="item">
<van-checkbox :name="item">复选框 {{ item }}</van-checkbox> <van-checkbox :name="item" />
</van-cell> </van-cell>
</van-cell-group> </van-cell-group>
</van-checkbox-group> </van-checkbox-group>

View File

@ -69,3 +69,9 @@ Vue.use(Vant);
```shell ```shell
vue init youzan/vue-cli-template-vant projectName vue init youzan/vue-cli-template-vant projectName
``` ```
### rem 适配
Vant 中的组件样式默认使用`px`作为单位,如果需要使用`rem`作为单位,推荐使用以下两个工具
- [postcss-pxtorem](https://github.com/cuth/postcss-pxtorem) 用于将单位转化为 rem
- [lib-flexible](https://github.com/amfe/lib-flexible) 用于设置 rem 基准值

View File

@ -46,8 +46,12 @@ export default {
```html ```html
<van-radio-group v-model="radio"> <van-radio-group v-model="radio">
<van-cell-group> <van-cell-group>
<van-cell><van-radio name="1">单选框 1</van-radio></van-cell> <van-cell :title="单选框 1" clickable @click="radio = '1'">
<van-cell><van-radio name="2">单选框 2</van-radio></van-cell> <van-radio name="1" />
</van-cell>
<van-cell :title="单选框 2" clickable @click="radio = '2'">
<van-radio name="2" />
</van-cell>
</van-cell-group> </van-cell-group>
</van-radio-group> </van-radio-group>
``` ```

View File

@ -67,7 +67,7 @@ Vue.use(Sku);
<!-- 自定义 sku-header-price --> <!-- 自定义 sku-header-price -->
<template slot="sku-header-price" slot-scope="props"> <template slot="sku-header-price" slot-scope="props">
<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">{{ props.price }}</span> only!!! <span class="van-sku__price-symbol"></span><span class="van-sku__price-num">{{ props.price }}</span>
</div> </div>
</template> </template>
<!-- 自定义 sku actions --> <!-- 自定义 sku actions -->

View File

@ -10,99 +10,56 @@ Vue.use(Slider);
#### 基本用法 #### 基本用法
```html ```html
<van-slider v-model="value1"/> <van-slider v-model="value" @change="onChange" />
<van-row>
<van-col span="12">
<van-stepper v-model="value1" />
</van-col>
</van-row>
``` ```
```js ```js
export default {
data() { data() {
return { return {
value1: 50 value: 50
};
},
methods: {
onChange(value) {
this.$toast('当前值:' + value);
} }
} }
};
``` ```
#### 最大最小值 #### 指定选择范围
```html ```html
<van-slider <van-slider v-model="value" :min="10" :max="90" />
v-model="value2"
:min="min"
:max="max"
/>
```
```js
data() {
return {
value2: 50,
min: 10,
max: 90
}
}
``` ```
#### 禁用 #### 禁用
```html ```html
<van-slider v-model="value3" disabled /> <van-slider v-model="value" disabled />
``` ```
#### 事件 #### 指定步长
```html ```html
<van-slider <van-slider v-model="value" :step="10" bar-height="4px" />
v-model="value4"
@change="handleChange"
@after-change="handleAfterChange"
/>
```
```js
data() {
return {
value4: 50
}
},
methods: {
handleChange(value) {
console.log('handleChange:', value)
},
handleAfterChange(value) {
console.log('handleAfterChange:', value)
}
}
```
### 自定义样式
```html
<van-slider
v-model="value5"
pivot-color="#333"
loaded-bar-color="red"
bar-color="blue"
/>
``` ```
### API ### API
| 参数 | 说明 | 类型 | 默认值 | 必须 | | 参数 | 说明 | 类型 | 默认值 |
|-----------|-----------|-----------|-------------|-------------| |-----------|-----------|-----------|-------------|
| value | 当前进度百分比 | Number | 0 | 否 | | value | 当前进度百分比 | `Number` | `0` |
| disabled | 滑块是否禁用 | Boolean | false | 否 | | disabled | 是否禁用滑块 | `Boolean` | `false` |
| bar-color | 进度条颜色 | string | `#cacaca` | 否 | | max | 最大值 | `Number` | `100` |
| loaded-bar-color | 已加载条颜色 | string | `#4b0` | 否 | | min | 最小值 | `Number` | `0` |
| pivot-color | 滑块颜色 | string | `#4b0` | 否 | | step | 步长 | `Number` | `1` |
| max | 最大值 | Number | 100 | - | | bar-height | 进度条高度 | `String` | `2px` |
| min | 最小值 | Number | 0 | - |
### Event ### Event
| 事件名 | 说明 | 参数 | | 事件名 | 说明 | 参数 |
|-----------|-----------|-----------| |-----------|-----------|-----------|
| change | 拖动时触发 | value | | change | 进度值改变后触发 | value: 当前进度 |
| after-change | 拖动停止后触发 | value |

View File

@ -41,6 +41,7 @@ export default {
| 参数 | 说明 | 类型 | 默认值 | 可选值 | | 参数 | 说明 | 类型 | 默认值 | 可选值 |
|-----------|-----------|-----------|-------------|-------------| |-----------|-----------|-----------|-------------|-------------|
| result-type | 文件读取结果类型 | `String` | `dataUrl` | `text` | | result-type | 文件读取结果类型 | `String` | `dataUrl` | `text` |
| accept | 接受的文件类型 | `String` | `image/*` | - |
| disabled | 是否禁用图片上传 | `Boolean` | `false` | - | | disabled | 是否禁用图片上传 | `Boolean` | `false` | - |
| before-read | 读取前的回调函数,返回 false 可终止文件读取 | `Function` | - | - | | before-read | 读取前的回调函数,返回 false 可终止文件读取 | `Function` | - | - |
| after-read | 读取完成后的回调函数 | `Function` | - | - | | after-read | 读取完成后的回调函数 | `Function` | - | - |

View File

@ -136,6 +136,10 @@ module.exports = {
path: '/progress', path: '/progress',
title: 'Progress - 进度条' title: 'Progress - 进度条'
}, },
{
path: '/slider',
title: 'Slider - 滑块'
},
{ {
path: '/stepper', path: '/stepper',
title: 'Stepper - 步进器' title: 'Stepper - 步进器'
@ -148,10 +152,6 @@ module.exports = {
path: '/swipe', path: '/swipe',
title: 'Swipe - 轮播' title: 'Swipe - 轮播'
}, },
{
path: '/slider',
title: 'Slider - 滑块'
},
{ {
path: '/tab', path: '/tab',
title: 'Tab - 标签页' title: 'Tab - 标签页'
@ -434,6 +434,10 @@ module.exports = {
path: '/progress', path: '/progress',
title: 'Progress' title: 'Progress'
}, },
{
path: '/slider',
title: 'Slider'
},
{ {
path: '/stepper', path: '/stepper',
title: 'Stepper' title: 'Stepper'
@ -446,10 +450,6 @@ module.exports = {
path: '/swipe', path: '/swipe',
title: 'Swipe' title: 'Swipe'
}, },
{
path: '/slider',
title: 'Slider'
},
{ {
path: '/tab', path: '/tab',
title: 'Tab' title: 'Tab'

View File

@ -12,6 +12,10 @@
"packages", "packages",
"types" "types"
], ],
"sideEffects": [
"es/**/style/*",
"lib/**/style/*"
],
"scripts": { "scripts": {
"bootstrap": "yarn || npm i && cd ./packages/vant-css/ && yarn || npm i && cd ../../", "bootstrap": "yarn || npm i && cd ./packages/vant-css/ && yarn || npm i && cd ../../",
"dev": "npm run build:file && webpack-dev-server --inline --config build/webpack.config.dev.js", "dev": "npm run build:file && webpack-dev-server --inline --config build/webpack.config.dev.js",

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="van-cell-group" :class="{ 'van-hairline--top-bottom': border }"> <div :class="[b(), { 'van-hairline--top-bottom': border }]">
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -1,19 +1,23 @@
<template> <template>
<div <div
v-clickoutside:touchstart="onClick" v-clickoutside:touchstart="onClick"
class="van-cell-swipe" :class="b()"
@click="onClick('cell')" @click="onClick('cell')"
@touchstart="startDrag" @touchstart="startDrag"
@touchmove="onDrag" @touchmove="onDrag"
@touchend="endDrag" @touchend="endDrag"
@touchcancel="endDrag" @touchcancel="endDrag"
> >
<div class="van-cell-swipe__wrapper" :style="wrapperStyle" @transitionend="swipe = false"> <div
<div class="van-cell-swipe__left" @click.stop="onClick('left')" v-if="leftWidth"> :class="b('wrapper')"
:style="wrapperStyle"
@transitionend="swipe = false"
>
<div v-if="leftWidth" :class="b('left')" @click.stop="onClick('left')">
<slot name="left" /> <slot name="left" />
</div> </div>
<slot /> <slot />
<div class="van-cell-swipe__right" @click.stop="onClick('right')" v-if="rightWidth"> <div v-if="rightWidth" :class="b('right')" @click.stop="onClick('right')">
<slot name="right" /> <slot name="right" />
</div> </div>
</div> </div>

View File

@ -1,37 +1,34 @@
<template> <template>
<div <div
class="van-cell" :class="[
:class="{ b({
'van-hairline': border, center,
'van-cell--center': center, required,
'van-cell--required': required, clickable: isLink || clickable
'van-cell--clickable': isLink || clickable }),
}" { 'van-hairline': border }
]"
@click="onClick" @click="onClick"
> >
<slot name="icon"> <slot name="icon">
<icon v-if="icon" class="van-cell__left-icon" :name="icon" /> <icon v-if="icon" :class="b('left-icon')" :name="icon" />
</slot> </slot>
<div class="van-cell__title" v-if="title || $slots.title"> <div v-if="title || $slots.title" :class="b('title')">
<slot name="title"> <slot name="title">
<span v-text="title" /> <span v-text="title" />
<div class="van-cell__label" v-if="label" v-text="label" /> <div v-if="label" v-text="label" :class="b('label')" />
</slot> </slot>
</div> </div>
<div <div
class="van-cell__value"
v-if="value || $slots.default" v-if="value || $slots.default"
:class="{ :class="b('value', { alone: !$slots.title && !title })"
'van-cell__value--link': isLink,
'van-cell__value--alone': !$slots.title && !title && !label
}"
> >
<slot> <slot>
<span v-text="value" /> <span v-text="value" />
</slot> </slot>
</div> </div>
<slot name="right-icon"> <slot name="right-icon">
<icon name="arrow" class="van-cell__right-icon" v-if="isLink" /> <icon v-if="isLink" :class="b('right-icon')" name="arrow" />
</slot> </slot>
<slot name="extra" /> <slot name="extra" />
</div> </div>

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="van-checkbox-group"> <div :class="b()">
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -1,16 +1,16 @@
<template> <template>
<div class="van-checkbox"> <div :class="b()">
<icon <icon
name="success" name="success"
class="van-checkbox__icon"
:class="[ :class="[
b('icon'),
`van-checkbox--${shape}`, { `van-checkbox--${shape}`, {
'van-checkbox--disabled': isDisabled, 'van-checkbox--disabled': isDisabled,
'van-checkbox--checked': isChecked 'van-checkbox--checked': isChecked
}]" }]"
@click="onClick" @click="onClick"
/> />
<span class="van-checkbox__label" @click="onClick('label')"> <span v-if="$slots.default" :class="b('label')" @click="onClick('label')">
<slot /> <slot />
</span> </span>
</div> </div>

View File

@ -1,11 +1,11 @@
<template> <template>
<div class="van-circle" :style="style"> <div :class="b()" :style="style">
<svg viewBox="0 0 1060 1060"> <svg viewBox="0 0 1060 1060">
<path class="van-circle__hover" :style="hoverStyle" :d="path" /> <path :class="b('hover')" :style="hoverStyle" :d="path" />
<path class="van-circle__layer" :style="layerStyle" :d="path" /> <path :class="b('layer')" :style="layerStyle" :d="path" />
</svg> </svg>
<slot> <slot>
<div class="van-circle__text">{{ text }}</div> <div :class="b('text')">{{ text }}</div>
</slot> </slot>
</div> </div>
</template> </template>

View File

@ -1,15 +1,14 @@
<template> <template>
<div <div
class="van-collapse-item" :class="[
:class="{ b({ expanded }),
'van-hairline--top': index, { 'van-hairline--top': index }
'van-collapse-item--expanded': expanded ]"
}"
> >
<cell class="van-collapse-item__title" is-link @click="onClick"> <cell :class="b('title')" is-link @click="onClick">
<slot name="title">{{ title }}</slot> <slot name="title">{{ title }}</slot>
</cell> </cell>
<div class="van-collapse-item__content" v-show="expanded"> <div v-show="expanded" :class="b('content')">
<slot /> <slot />
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="van-collapse van-hairline--top-bottom"> <div :class="b()" class="van-hairline--top-bottom">
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -1,19 +1,19 @@
<template> <template>
<div class="van-contact-card" :class="[`van-contact-card--${type}`, { 'van-contact-card--uneditable': !editable }]" @click="onClick"> <div :class="b([type, { uneditable: !editable }])" @click="onClick">
<div class="van-contact-card__content"> <div :class="b('content')">
<template v-if="type === 'add'"> <template v-if="type === 'add'">
<icon class="van-contact-card__icon" name="add2" /> <icon :class="b('icon')" name="add2" />
<div class="van-contact-card__text">{{ addText || $t('addText') }}</div> <div :class="b('text')">{{ addText || $t('addText') }}</div>
</template> </template>
<template v-else-if="type === 'edit'"> <template v-else-if="type === 'edit'">
<icon class="van-contact-card__icon" name="contact" /> <icon :class="b('icon')" name="contact" />
<div class="van-contact-card__text"> <div :class="b('text')">
<div>{{ $t('contact') }}{{ name }}</div> <div>{{ $t('contact') }}{{ name }}</div>
<div>{{ $t('tel') }}{{ tel }}</div> <div>{{ $t('tel') }}{{ tel }}</div>
</div> </div>
</template> </template>
</div> </div>
<icon v-if="editable" class="van-contact-card__arrow" name="arrow" /> <icon v-if="editable" :class="b('arrow')" name="arrow" />
</div> </div>
</template> </template>

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="van-contact-edit"> <div :class="b()">
<cell-group> <cell-group>
<field <field
v-model="data.name" v-model="data.name"
@ -18,7 +18,7 @@
@focus="onFocus('tel')" @focus="onFocus('tel')"
/> />
</cell-group> </cell-group>
<div class="van-contact-edit__buttons"> <div :class="b('buttons')">
<van-button block :loading="isSaving" @click="onSave" type="primary">{{ $t('save') }}</van-button> <van-button block :loading="isSaving" @click="onSave" type="primary">{{ $t('save') }}</van-button>
<van-button block :loading="isDeleting" @click="onDelete" v-if="isEdit">{{ $t('delete') }}</van-button> <van-button block :loading="isDeleting" @click="onDelete" v-if="isEdit">{{ $t('delete') }}</van-button>
</div> </div>

View File

@ -1,20 +1,21 @@
<template> <template>
<div class="van-contact-list"> <div :class="b()">
<radio-group :value="value" @input="$emit('input', $event)"> <radio-group :value="value" @input="$emit('input', $event)">
<cell-group> <cell-group>
<cell v-for="(item, index) in list" :key="item.id" is-link> <cell v-for="(item, index) in list" :key="item.id" is-link>
<radio :name="item.id" @click="$emit('select', item, index)"> <radio :name="item.id" @click="$emit('select', item, index)">
<p class="van-contact-list__text">{{ $t('contact') }}{{ item.name }}</p> <p :class="b('text')">{{ $t('contact') }}{{ item.name }}</p>
<p class="van-contact-list__text">{{ $t('tel') }}{{ item.tel }}</p> <p :class="b('text')">{{ $t('tel') }}{{ item.tel }}</p>
</radio> </radio>
<icon slot="right-icon" name="edit" class="van-contact-list__edit" @click="$emit('edit', item, index)" /> <icon slot="right-icon" name="edit" :class="b('edit')" @click="$emit('edit', item, index)" />
</cell> </cell>
</cell-group> </cell-group>
</radio-group> </radio-group>
<cell <cell
icon="add" icon="add"
is-link is-link
class="van-contact-list__add van-hairline--top" :class="b('add')"
class="van-hairline--top"
:title="addText || $t('addText')" :title="addText || $t('addText')"
@click="$emit('add')" @click="$emit('add')"
/> />

View File

@ -1,5 +1,5 @@
<template> <template>
<cell-group class="van-coupon-cell"> <cell-group :class="b()">
<cell :title="title || $t('title')" :value="value" :is-link="editable" @click="$emit('click')" /> <cell :title="title || $t('title')" :value="value" :is-link="editable" @click="$emit('click')" />
</cell-group> </cell-group>
</template> </template>

View File

@ -1,17 +1,17 @@
<template> <template>
<div class="van-coupon-item" :class="{ 'van-coupon-item--disabled': disabled }"> <div :class="b({ disabled })">
<div class="van-coupon-item__head"> <div :class="b('head')">
<div class="van-coupon-item__lines" /> <div :class="b('lines')" />
<div class="van-coupon-item__gradient"> <div :class="b('gradient')">
<h2 v-html="faceAmount" /> <h2 v-html="faceAmount" />
<p>{{ conditionMessage }}</p> <p>{{ conditionMessage }}</p>
</div> </div>
</div> </div>
<div class="van-coupon-item__body"> <div :class="b('body')">
<h2>{{ data.name }}</h2> <h2>{{ data.name }}</h2>
<span>{{ validPeriod }}</span> <span>{{ validPeriod }}</span>
<p v-if="disabled && data.reason">{{ data.reason }}</p> <p v-if="disabled && data.reason">{{ data.reason }}</p>
<div class="van-coupon-item__corner" v-if="chosen"> <div v-if="chosen" :class="b('corner')" >
<icon name="success" /> <icon name="success" />
</div> </div>
</div> </div>
@ -34,6 +34,7 @@ export default create({
validPeriod() { validPeriod() {
return `${this.getDate(this.data.start_at)}-${this.getDate(this.data.end_at)}`; return `${this.getDate(this.data.start_at)}-${this.getDate(this.data.end_at)}`;
}, },
faceAmount() { faceAmount() {
return this.data.denominations !== 0 return this.data.denominations !== 0
? `<span>¥</span> ${this.formatAmount(this.data.denominations)}` ? `<span>¥</span> ${this.formatAmount(this.data.denominations)}`
@ -41,6 +42,7 @@ export default create({
? this.formatDiscount(this.data.discount) ? this.formatDiscount(this.data.discount)
: ''; : '';
}, },
conditionMessage() { conditionMessage() {
let condition = this.data.origin_condition; let condition = this.data.origin_condition;
condition = condition % 100 === 0 ? Math.round(condition / 100) : (condition / 100).toFixed(2); condition = condition % 100 === 0 ? Math.round(condition / 100) : (condition / 100).toFixed(2);
@ -53,12 +55,15 @@ export default create({
const date = new Date(timeStamp * 1000); const date = new Date(timeStamp * 1000);
return `${date.getFullYear()}.${this.padZero(date.getMonth() + 1)}.${this.padZero(date.getDate())}`; return `${date.getFullYear()}.${this.padZero(date.getMonth() + 1)}.${this.padZero(date.getDate())}`;
}, },
padZero(num) { padZero(num) {
return (num < 10 ? '0' : '') + num; return (num < 10 ? '0' : '') + num;
}, },
formatDiscount(discount) { formatDiscount(discount) {
return this.$t('discount', `${(discount / 10).toFixed(discount % 10 === 0 ? 0 : 1)}`); return this.$t('discount', `${(discount / 10).toFixed(discount % 10 === 0 ? 0 : 1)}`);
}, },
formatAmount(amount) { formatAmount(amount) {
return (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2); return (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
} }

View File

@ -1,8 +1,9 @@
<template> <template>
<div class="van-coupon-list"> <div :class="b()">
<cell-group class="van-coupon-list__top" v-if="showExchangeBar"> <cell-group v-if="showExchangeBar" :class="b('top')">
<field <field
class="van-coupon-list__filed van-hairline--surround" :class="b('field')"
class="van-hairline--surround"
v-model="currentCode" v-model="currentCode"
:placeholder="inputPlaceholder || $t('placeholder')" :placeholder="inputPlaceholder || $t('placeholder')"
:maxlength="20" :maxlength="20"
@ -10,14 +11,14 @@
<van-button <van-button
size="small" size="small"
type="danger" type="danger"
class="van-coupon-list__exchange" :class="b('exchange')"
:text="exchangeButtonText || $t('exchange')" :text="exchangeButtonText || $t('exchange')"
:loading="exchangeButtonLoading" :loading="exchangeButtonLoading"
:disabled="buttonDisabled" :disabled="buttonDisabled"
@click="onClickExchangeButton" @click="onClickExchangeButton"
/> />
</cell-group> </cell-group>
<div class="van-coupon-list__list" :class="{ 'van-coupon-list--with-exchange': showExchangeBar }" ref="list"> <div :class="b('list', { 'with-exchange': showExchangeBar })" ref="list">
<coupon-item <coupon-item
ref="card" ref="card"
v-for="(item, index) in coupons" v-for="(item, index) in coupons"
@ -33,7 +34,7 @@
:key="item.id || item.name" :key="item.id || item.name"
:data="item" :data="item"
/> />
<div class="van-coupon-list__empty" v-if="!coupons.length && !disabledCoupons.length"> <div v-if="!coupons.length && !disabledCoupons.length" :class="b('empty')">
<img src="https://img.yzcdn.cn/v2/image/wap/trade/new_order/empty@2x.png" > <img src="https://img.yzcdn.cn/v2/image/wap/trade/new_order/empty@2x.png" >
<p>{{ $t('empty') }}</p> <p>{{ $t('empty') }}</p>
</div> </div>
@ -41,7 +42,8 @@
<div <div
v-show="showCloseButton" v-show="showCloseButton"
v-text="closeButtonText || $t('close')" v-text="closeButtonText || $t('close')"
class="van-coupon-list__close van-hairline--top" :class="b('close')"
class="van-hairline--top"
@click="$emit('change', -1)" @click="$emit('change', -1)"
/> />
</div> </div>

View File

@ -1,18 +1,18 @@
<template> <template>
<transition name="van-dialog-bounce"> <transition name="van-dialog-bounce">
<div class="van-dialog" v-show="value"> <div v-show="value" :class="b()">
<div class="van-dialog__header" v-if="title" v-text="title" /> <div v-if="title" v-text="title" :class="b('header')" />
<div class="van-dialog__content van-hairline"> <div :class="b('content')" class="van-hairline">
<slot> <slot>
<div class="van-dialog__message" v-if="message" :class="{ 'van-dialog__message--withtitle': title }" v-html="message" /> <div v-if="message" v-html="message" :class="b('message', { withtitle: title })" />
</slot> </slot>
</div> </div>
<div class="van-dialog__footer" :class="{ 'is-twobtn': showCancelButton && showConfirmButton }"> <div :class="b('footer', { 'buttons': showCancelButton && showConfirmButton })">
<van-button <van-button
v-show="showCancelButton" v-show="showCancelButton"
:loading="loading.cancel" :loading="loading.cancel"
size="large" size="large"
class="van-dialog__cancel" :class="b('cancel')"
@click="handleAction('cancel')" @click="handleAction('cancel')"
> >
{{ cancelButtonText || $t('cancel') }} {{ cancelButtonText || $t('cancel') }}
@ -21,8 +21,7 @@
v-show="showConfirmButton" v-show="showConfirmButton"
size="large" size="large"
:loading="loading.confirm" :loading="loading.confirm"
class="van-dialog__confirm" :class="[b('confirm'), { 'van-hairline--left': showCancelButton && showConfirmButton }]"
:class="{ 'van-hairline--left': showCancelButton && showConfirmButton }"
@click="handleAction('confirm')" @click="handleAction('confirm')"
> >
{{ confirmButtonText || $t('confirm') }} {{ confirmButtonText || $t('confirm') }}

View File

@ -3,46 +3,45 @@
:title="label" :title="label"
:center="center" :center="center"
:required="required" :required="required"
class="van-field" :class="b({
:class="{ error,
'van-field--disabled': $attrs.disabled, disabled: $attrs.disabled,
'van-field--error': error, 'has-icon': hasIcon,
'van-field--min-height': type === 'textarea' && !autosize, 'min-height': type === 'textarea' && !autosize
'van-field--has-icon': hasIcon })"
}"
> >
<textarea <textarea
v-if="type === 'textarea'" v-if="type === 'textarea'"
v-bind="$attrs" v-bind="$attrs"
v-on="listeners" v-on="listeners"
ref="textarea" ref="textarea"
class="van-field__control" :class="b('control')"
:value="value" :value="value"
/> />
<input <input
v-else v-else
v-bind="$attrs" v-bind="$attrs"
v-on="listeners" v-on="listeners"
class="van-field__control" :class="b('control')"
:type="type" :type="type"
:value="value" :value="value"
> >
<div <div
v-if="errorMessage" v-if="errorMessage"
v-text="errorMessage" v-text="errorMessage"
class="van-field__error-message" :class="b('error-message')"
/> />
<div <div
v-if="hasIcon" v-if="hasIcon"
v-show="$slots.icon || value" v-show="$slots.icon || value"
class="van-field__icon" :class="b('icon')"
@touchstart.prevent="onClickIcon" @touchstart.prevent="onClickIcon"
> >
<slot name="icon"> <slot name="icon">
<icon :name="icon" /> <icon :name="icon" />
</slot> </slot>
</div> </div>
<div class="van-field__button" v-if="$slots.button" slot="extra"> <div v-if="$slots.button" :class="b('button')" slot="extra">
<slot name="button" /> <slot name="button" />
</div> </div>
</cell> </cell>

View File

@ -2,7 +2,7 @@
<van-button <van-button
tag="a" tag="a"
:href="url" :href="url"
class="van-goods-action__big-btn" :class="b()"
:type="primary ? 'primary' : 'default'" :type="primary ? 'primary' : 'default'"
bottom-action bottom-action
@click="onClick" @click="onClick"

View File

@ -1,6 +1,6 @@
<template> <template>
<a :href="url" class="van-goods-action__mini-btn van-hairline" @click="onClick"> <a :href="url" :class="b()" class="van-hairline" @click="onClick">
<icon class="van-goods-action__mini-btn-icon" :class="iconClass" :info="info" :name="icon" /> <icon :class="[b('icon'), iconClass]" :info="info" :name="icon" />
<slot>{{ text }}</slot> <slot>{{ text }}</slot>
</a> </a>
</template> </template>

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="van-goods-action"> <div :class="b()">
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -1,7 +1,7 @@
<template> <template>
<i class="van-icon" :class="`van-icon-${name}`" v-on="$listeners"> <i :class="[b(), `van-icon-${name}`]" v-on="$listeners">
<slot /> <slot />
<div v-if="isDef(info)" class="van-icon__info">{{ info }}</div> <div v-if="isDef(info)" :class="b('info')">{{ info }}</div>
</i> </i>
</template> </template>

View File

@ -1,7 +1,7 @@
<template> <template>
<div <div
v-show="value" v-show="value"
class="van-image-preview" :class="b()"
@touchstart="onTouchStart" @touchstart="onTouchStart"
@touchmove.prevent="touchMove" @touchmove.prevent="touchMove"
@touchend="onTouchEnd" @touchend="onTouchEnd"
@ -9,7 +9,7 @@
> >
<swipe :initial-swipe="startPosition"> <swipe :initial-swipe="startPosition">
<swipe-item v-for="(item, index) in images" :key="index"> <swipe-item v-for="(item, index) in images" :key="index">
<img class="van-image-preview__image" :src="item" > <img :class="b('image')" :src="item" >
</swipe-item> </swipe-item>
</swipe> </swipe>
</div> </div>

View File

@ -1,10 +1,10 @@
<template> <template>
<div class="van-list"> <div :class="b()">
<slot /> <slot />
<div class="van-list__loading" v-show="loading"> <div v-show="loading" :class="b('loading')">
<slot name="loading"> <slot name="loading">
<loading /> <loading />
<span class="van-list__loading-text">{{ $t('loadingTip') }}</span> <span :class="b('loading-text')">{{ $t('loadingTip') }}</span>
</slot> </slot>
</div> </div>
</div> </div>

View File

@ -1,8 +1,8 @@
<template> <template>
<div class="van-loading" :class="['van-loading--' + type, 'van-loading--' + color]" :style="style"> <div :class="b([type, color])" :style="style">
<span class="van-loading__spinner" :class="'van-loading__spinner--' + type"> <span :class="b('spinner', type)">
<i v-for="item in (type === 'spinner' ? 12 : 0)" /> <i v-for="item in (type === 'spinner' ? 12 : 0)" />
<svg v-if="type === 'circular'" class="van-loading__circular" viewBox="25 25 50 50"> <svg v-if="type === 'circular'" :class="b('circular')" viewBox="25 25 50 50">
<circle cx="50" cy="50" r="20" fill="none"/> <circle cx="50" cy="50" r="20" fill="none"/>
</svg> </svg>
</span> </span>

View File

@ -39,7 +39,7 @@ export default {
} }
el = join(name, el, ELEMENT); el = join(name, el, ELEMENT);
return mods ? [el, prefix(name, mods)] : el; return mods ? [el, prefix(el, mods)] : el;
} }
} }
}; };

View File

@ -1,21 +1,21 @@
<template> <template>
<div <div
class="van-nav-bar van-hairline--bottom" class="van-hairline--bottom"
:class="{ 'van-nav-bar--fixed': fixed }" :class="b({ fixed })"
:style="style" :style="style"
> >
<div class="van-nav-bar__left" @click="$emit('click-left')"> <div :class="b('left')" @click="$emit('click-left')">
<slot name="left"> <slot name="left">
<icon v-if="leftArrow" class="van-nav-bar__arrow" name="arrow" /> <icon v-if="leftArrow" :class="b('arrow')" name="arrow" />
<span v-if="leftText" v-text="leftText" class="van-nav-bar__text" /> <span v-if="leftText" v-text="leftText" :class="b('text')" />
</slot> </slot>
</div> </div>
<div class="van-nav-bar__title van-ellipsis"> <div :class="b('title')" class="van-ellipsis">
<slot name="title">{{ title }}</slot> <slot name="title">{{ title }}</slot>
</div> </div>
<div class="van-nav-bar__right" @click="$emit('click-right')"> <div :class="b('right')" @click="$emit('click-right')">
<slot name="right"> <slot name="right">
<span v-if="rightText" v-text="rightText" class="van-nav-bar__text" /> <span v-if="rightText" v-text="rightText" :class="b('text')" />
</slot> </slot>
</div> </div>
</div> </div>

View File

@ -1,19 +1,17 @@
<template> <template>
<div <div
v-show="showNoticeBar" v-show="showNoticeBar"
class="van-notice-bar" :class="b({ withicon: mode })"
:class="{ 'van-notice-bar--withicon': mode }"
:style="barStyle" :style="barStyle"
@click="$emit('click')" @click="$emit('click')"
> >
<div class="van-notice-bar__left-icon" v-if="leftIcon"> <div v-if="leftIcon" :class="b('left-icon')">
<img :src="leftIcon" > <img :src="leftIcon" >
</div> </div>
<div class="van-notice-bar__content-wrap" ref="contentWrap"> <div :class="b('wrap')" ref="wrap">
<div <div
ref="content" ref="content"
class="van-notice-bar__content" :class="[b('content'), animationClass]"
:class="animationClass"
:style="contentStyle" :style="contentStyle"
@animationend="onAnimationEnd" @animationend="onAnimationEnd"
@webkitAnimationEnd="onAnimationEnd" @webkitAnimationEnd="onAnimationEnd"
@ -21,7 +19,12 @@
<slot>{{ text }}</slot> <slot>{{ text }}</slot>
</div> </div>
</div> </div>
<icon class="van-notice-bar__right-icon" :name="iconName" v-if="iconName" @click="onClickIcon" /> <icon
v-if="iconName"
:class="b('right-icon')"
:name="iconName"
@click="onClickIcon"
/>
</div> </div>
</template> </template>
@ -95,21 +98,23 @@ export default create({
onClickIcon() { onClickIcon() {
this.showNoticeBar = this.mode !== 'closeable'; this.showNoticeBar = this.mode !== 'closeable';
}, },
onAnimationEnd() { onAnimationEnd() {
this.firstRound = false; this.firstRound = false;
this.$nextTick(() => { this.$nextTick(() => {
this.duration = (this.offsetWidth + this.wrapWidth) / this.speed; this.duration = (this.offsetWidth + this.wrapWidth) / this.speed;
this.animationClass = 'van-notice-bar__play--infinite'; this.animationClass = this.b('play--infinite');
}); });
}, },
initAnimation() { initAnimation() {
const offsetWidth = this.$refs.content.getBoundingClientRect().width; const offsetWidth = this.$refs.content.getBoundingClientRect().width;
const wrapWidth = this.$refs.contentWrap.getBoundingClientRect().width; const wrapWidth = this.$refs.wrap.getBoundingClientRect().width;
if (this.scrollable && offsetWidth > wrapWidth) { if (this.scrollable && offsetWidth > wrapWidth) {
this.wrapWidth = wrapWidth; this.wrapWidth = wrapWidth;
this.offsetWidth = offsetWidth; this.offsetWidth = offsetWidth;
this.duration = offsetWidth / this.speed; this.duration = offsetWidth / this.speed;
this.animationClass = 'van-notice-bar__play'; this.animationClass = this.b('play');
} }
} }
} }

View File

@ -5,13 +5,17 @@
@touchmove="onBlur" @touchmove="onBlur"
@touchend="onBlur" @touchend="onBlur"
@touchcancel="onBlur" @touchcancel="onBlur"
class="van-hairline van-key" class="van-hairline"
:class="className" :class="[b(), className]"
/> />
</template> </template>
<script> <script>
export default { import create from '../utils/create';
export default create({
name: 'key',
props: { props: {
text: [String, Number], text: [String, Number],
type: { type: {
@ -31,7 +35,7 @@ export default {
const types = this.type.slice(0); const types = this.type.slice(0);
this.active && types.push('active'); this.active && types.push('active');
return types.map(type => `van-key--${type}`); return types.map(type => this.b([type]));
} }
}, },
@ -45,5 +49,5 @@ export default {
this.active = false; this.active = false;
} }
} }
}; });
</script> </script>

View File

@ -3,30 +3,29 @@
<div <div
v-show="show" v-show="show"
:style="style" :style="style"
class="van-number-keyboard" :class="b([theme])"
:class="`van-number-keyboard--${theme}`"
@animationend="onAnimationEnd" @animationend="onAnimationEnd"
@webkitAnimationEnd="onAnimationEnd" @webkitAnimationEnd="onAnimationEnd"
> >
<div class="van-number-keyboard__title van-hairline--top" v-if="title || showTitleClose"> <div :class="b('title')" class="van-hairline--top" v-if="title || showTitleClose">
<span v-text="title" /> <span v-text="title" />
<span <span
class="van-number-keyboard__close" :class="b('close')"
v-if="showTitleClose" v-if="showTitleClose"
v-text="closeButtonText" v-text="closeButtonText"
@click="onBlur" @click="onBlur"
/> />
</div> </div>
<div class="van-number-keyboard__body"> <div :class="b('body')">
<key <key
v-for="(key, index) in keys" v-for="(key, index) in keys"
:key="index" :key="key.text"
:text="key.text" :text="key.text"
:type="key.type" :type="key.type"
@press="onPressKey" @press="onPressKey"
/> />
</div> </div>
<div class="van-number-keyboard__sidebar" v-if="theme === 'custom'"> <div v-if="theme === 'custom'" :class="b('sidebar')">
<key :text="'delete'" :type="['delete', 'big']" @press="onPressKey" /> <key :text="'delete'" :type="['delete', 'big']" @press="onPressKey" />
<key :text="closeButtonText" :type="['green', 'big']" @press="onPressKey" /> <key :text="closeButtonText" :type="['green', 'big']" @press="onPressKey" />
</div> </div>

View File

@ -1,8 +1,8 @@
<template> <template>
<ul class="van-pagination" :class="{ 'van-pagination-simple': !isMultiMode }"> <ul :class="b({ simple: !isMultiMode })">
<li <li
class="van-pagination__item van-pagination__prev van-hairline" class="van-hairline"
:class="{ 'van-pagination--disabled': value === 1 }" :class="[b('item', { disabled: value === 1 }), b('prev')]"
@click="selectPage(value - 1)" @click="selectPage(value - 1)"
> >
{{ prevText || $t('prev') }} {{ prevText || $t('prev') }}
@ -10,18 +10,18 @@
<li <li
v-if="isMultiMode" v-if="isMultiMode"
v-for="(page, index) in pages" v-for="(page, index) in pages"
class="van-pagination__item van-pagination__page van-hairline" class="van-hairline"
:class="{ 'van-pagination--active': page.active }" :class="[b('item', { active: page.active }), b('page')]"
@click="selectPage(page.number)" @click="selectPage(page.number)"
> >
{{ page.text }} {{ page.text }}
</li> </li>
<li v-if="!isMultiMode" class="van-pagination__page-desc"> <li v-if="!isMultiMode" :class="b('page-desc')">
<slot name="pageDesc">{{ pageDesc }}</slot> <slot name="pageDesc">{{ pageDesc }}</slot>
</li> </li>
<li <li
class="van-pagination__item van-pagination__next van-hairline" class="van-hairline"
:class="{ 'van-pagination--disabled': value === computedPageCount }" :class="[b('item', { disabled: value === computedPageCount }), b('next')]"
@click="selectPage(value + 1)" @click="selectPage(value + 1)"
> >
{{ nextText || $t('next') }} {{ nextText || $t('next') }}

View File

@ -1,19 +1,15 @@
<template> <template>
<div class="van-panel van-hairline--top-bottom"> <cell-group :class="b()">
<div class="van-panel__header van-hairline--bottom">
<slot name="header"> <slot name="header">
<div class="van-panel__title" v-text="title" /> <cell :class="b('header')" :title="title" :label="desc" :value="status" />
<span class="van-panel__desc" v-if="desc" v-text="desc" />
<span class="van-panel__status" v-if="status" v-text="status" />
</slot> </slot>
</div> <div :class="b('content')">
<div class="van-panel__content">
<slot /> <slot />
</div> </div>
<div class="van-panel__footer van-hairline--top" v-if="$slots.footer"> <div v-if="$slots.footer" :class="b('footer')" class="van-hairline--top">
<slot name="footer" /> <slot name="footer" />
</div> </div>
</div> </cell-group>
</template> </template>
<script> <script>

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="van-password-input"> <div :class="b()">
<ul class="van-password-input__security van-hairline--surround" @touchstart.stop="$emit('focus')"> <ul :class="b('security')" class="van-hairline--surround" @touchstart.stop="$emit('focus')">
<li v-for="visibility in points" class="van-hairline"> <li v-for="visibility in points" class="van-hairline">
<i :style="`visibility: ${visibility}`" /> <i :style="`visibility: ${visibility}`" />
</li> </li>
@ -8,7 +8,7 @@
<div <div
v-if="errorInfo || info" v-if="errorInfo || info"
v-text="errorInfo || info" v-text="errorInfo || info"
:class="errorInfo ? 'van-password-input__error-info' : 'van-password-input__info'" :class="b(errorInfo ? 'error-info' : 'info')"
/> />
</div> </div>
</template> </template>

View File

@ -1,8 +1,7 @@
<template> <template>
<div <div
class="van-picker-column" :class="[b(), className]"
:class="className"
:style="columnStyle" :style="columnStyle"
@touchstart="onTouchStart" @touchstart="onTouchStart"
@touchmove.prevent="onTouchMove" @touchmove.prevent="onTouchMove"
@ -14,10 +13,10 @@
v-for="(option, index) in options" v-for="(option, index) in options"
v-text="getOptionText(option)" v-text="getOptionText(option)"
class="van-ellipsis" class="van-ellipsis"
:class="{ :class="b('item', {
'van-picker-column--disabled': isDisabled(option), disabled: isDisabled(option),
'van-picker-column--selected': index === currentIndex selected: index === currentIndex
}" })"
@click="setIndex(index, true)" @click="setIndex(index, true)"
/> />
</ul> </ul>

View File

@ -1,16 +1,16 @@
<template> <template>
<div class="van-picker"> <div :class="b()">
<div class="van-picker__toolbar van-hairline--top-bottom" v-if="showToolbar"> <div :class="b('toolbar')" class="van-hairline--top-bottom" v-if="showToolbar">
<slot> <slot>
<div class="van-picker__cancel" @click="emit('cancel')">{{ cancelButtonText || $t('cancel') }}</div> <div :class="b('cancel')" @click="emit('cancel')">{{ cancelButtonText || $t('cancel') }}</div>
<div class="van-picker__title van-ellipsis" v-if="title" v-text="title" /> <div :class="b('title')" class="van-ellipsis" v-if="title" v-text="title" />
<div class="van-picker__confirm" @click="emit('confirm')">{{ confirmButtonText || $t('confirm') }}</div> <div :class="b('confirm')" @click="emit('confirm')">{{ confirmButtonText || $t('confirm') }}</div>
</slot> </slot>
</div> </div>
<div v-if="loading" class="van-picker__loading"> <div v-if="loading" :class="b('loading')">
<loading /> <loading />
</div> </div>
<div class="van-picker__columns" :style="columnsStyle" @touchmove.prevent> <div :class="b('columns')" :style="columnsStyle" @touchmove.prevent>
<picker-column <picker-column
v-for="(item, index) in currentColumns" v-for="(item, index) in currentColumns"
:key="index" :key="index"
@ -22,7 +22,7 @@
:visible-item-count="visibleItemCount" :visible-item-count="visibleItemCount"
@change="onChange(index)" @change="onChange(index)"
/> />
<div class="van-picker__frame van-hairline--top-bottom" :style="frameStyle" /> <div :class="b('frame')" class="van-hairline--top-bottom" :style="frameStyle" />
</div> </div>
</div> </div>
</template> </template>

View File

@ -1,6 +1,6 @@
<template> <template>
<transition :name="currentTransition"> <transition :name="currentTransition">
<div v-show="value" class="van-popup" :class="{ [`van-popup--${position}`]: position }"> <div v-show="value" :class="b({ [position]: position })">
<slot /> <slot />
</div> </div>
</transition> </transition>
@ -31,12 +31,10 @@ export default create({
} }
}, },
data() { computed: {
const transition = this.transition || (this.position === '' ? 'van-fade' : `popup-slide-${this.position}`); currentTransition() {
return { return this.transition || (this.position === '' ? 'van-fade' : `popup-slide-${this.position}`);
currentValue: false, }
currentTransition: transition
};
} }
}); });
</script> </script>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="van-progress"> <div :class="b()">
<span class="van-progress__portion" :style="portionStyle" /> <span :class="b('portion')" :style="portionStyle" />
<span class="van-progress__pivot" v-show="showPivot" :style="pivotStyle">{{ pivotText }}</span> <span :class="b('pivot')" v-show="showPivot" :style="pivotStyle">{{ pivotText }}</span>
</div> </div>
</template> </template>

View File

@ -1,23 +1,23 @@
<template> <template>
<div class="van-pull-refresh"> <div :class="b()">
<div <div
class="van-pull-refresh__track" :class="b('track')"
:style="style" :style="style"
@touchstart="onTouchStart" @touchstart="onTouchStart"
@touchmove="onTouchMove" @touchmove="onTouchMove"
@touchend="onTouchEnd" @touchend="onTouchEnd"
@touchcancel="onTouchEnd" @touchcancel="onTouchEnd"
> >
<div class="van-pull-refresh__head"> <div :class="b('head')">
<slot name="normal" v-if="status === 'normal'"/> <slot v-if="status === 'normal'" name="normal" />
<slot name="pulling" v-if="status === 'pulling'"> <slot v-if="status === 'pulling'" name="pulling">
<span class="van-pull-refresh__text">{{ pullingText || $t('pulling') }}</span> <span :class="b('text')">{{ pullingText || $t('pulling') }}</span>
</slot> </slot>
<slot name="loosing" v-if="status === 'loosing'"> <slot v-if="status === 'loosing'" name="loosing">
<span class="van-pull-refresh__text">{{ loosingText || $t('loosing') }}</span> <span :class="b('text')">{{ loosingText || $t('loosing') }}</span>
</slot> </slot>
<slot name="loading" v-if="status === 'loading'"> <slot v-if="status === 'loading'" name="loading">
<div class="van-pull-refresh__loading"> <div :class="b('loading')">
<loading /> <loading />
<span>{{ loadingText || $t('loadingTip') }}</span> <span>{{ loadingText || $t('loadingTip') }}</span>
</div> </div>

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="van-radio-group"> <div :class="b()">
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -1,20 +1,16 @@
<template> <template>
<div <div :class="b({ disabled: isDisabled })" @click="$emit('click')">
class="van-radio" <span :class="b('input')">
:class="{ 'van-radio--disabled': isDisabled }"
@click="$emit('click')"
>
<span class="van-radio__input">
<input <input
:value="name" :value="name"
v-model="currentValue" v-model="currentValue"
type="radio" type="radio"
class="van-radio__control" :class="b('control')"
:disabled="isDisabled" :disabled="isDisabled"
> >
<icon :name="currentValue === name ? 'checked' : 'check'" /> <icon :name="currentValue === name ? 'checked' : 'check'" />
</span> </span>
<span class="van-radio__label" @click="onClickLabel"> <span v-if="$slots.default" :class="b('label')" @click="onClickLabel">
<slot /> <slot />
</span> </span>
</div> </div>

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="van-row" :style="style"> <div :class="b()" :style="style">
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -1,23 +1,23 @@
<template> <template>
<div <div
class="van-search" :class="b({ 'show-action': showAction })"
:class="{ 'van-search--show-action': showAction }" :style="{ 'background-color': background }"
:style="{ 'background-color': background }"> >
<div class="van-search__input-wrap" v-clickoutside="onClickoutside"> <div :class="b('wrap')" v-clickoutside="onClickoutside">
<icon name="search" /> <icon name="search" />
<input <input
v-bind="$attrs" v-bind="$attrs"
v-on="listeners" v-on="listeners"
v-refocus="focusStatus" v-refocus="focusStatus"
type="search" type="search"
class="van-search__input" :class="b('input')"
:value="value" :value="value"
> >
<icon name="clear" v-show="isFocus && value" @click="onClean" /> <icon name="clear" v-show="isFocus && value" @click="onClean" />
</div> </div>
<div class="van-search__action" v-if="showAction"> <div v-if="showAction" :class="b('action')" >
<slot name="action"> <slot name="action">
<div class="van-search__action-text" @click="onBack">{{ $t('cancel') }}</div> <div :class="b('cancel')" @click="onBack">{{ $t('cancel') }}</div>
</slot> </slot>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="van-sku-actions"> <div :class="b()">
<van-button <van-button
v-if="showAddCartBtn" v-if="showAddCartBtn"
bottom-action bottom-action

View File

@ -1,9 +1,9 @@
<template> <template>
<div class="van-sku-header van-hairline--bottom"> <div :class="b()" class="van-hairline--bottom">
<div class="van-sku-header__img-wrap"> <div :class="b('img-wrap')">
<img :src="goodsImg" > <img :src="goodsImg" >
</div> </div>
<div class="van-sku-header__goods-info"> <div :class="b('goods-info')">
<div class="van-sku__goods-name van-ellipsis">{{ goods.title }}</div> <div class="van-sku__goods-name van-ellipsis">{{ goods.title }}</div>
<!-- price display area --> <!-- price display area -->
<slot /> <slot />

View File

@ -1,14 +1,13 @@
<template> <template>
<div class="van-sku-img-uploader"> <div :class="b()">
<!-- 头部 --> <!-- 头部 -->
<van-uploader <van-uploader
:disabled="!!paddingImg" :disabled="!!paddingImg"
:after-read="afterReadFile" :after-read="afterReadFile"
:max-size="maxSize * 1024 * 1024" :max-size="maxSize * 1024 * 1024"
accept="image/*"
@oversize="$toast($t('maxSize', maxSize))" @oversize="$toast($t('maxSize', maxSize))"
> >
<div class="van-sku-img-uploader__header"> <div :class="b('header')">
<div v-if="paddingImg">{{ $t('uploading') }}</div> <div v-if="paddingImg">{{ $t('uploading') }}</div>
<template v-else> <template v-else>
<icon name="photograph" /> <icon name="photograph" />
@ -23,15 +22,15 @@
<!-- 已有的图片,图片右上角显示删除按钮 --> <!-- 已有的图片,图片右上角显示删除按钮 -->
<div <div
v-for="(img, index) in imgList" v-for="(img, index) in imgList"
class="van-sku-img-uploader__img" :class="b('img')"
> >
<img :src="img"> <img :src="img">
<icon name="clear" class="van-sku-img-uploader__delete" @click="$emit('input', '')" /> <icon name="clear" :class="b('delete')" @click="$emit('input', '')" />
</div> </div>
<!-- 正在上传的图片,有上传等待提示 --> <!-- 正在上传的图片,有上传等待提示 -->
<div v-if="paddingImg" class="van-sku-img-uploader__img"> <div v-if="paddingImg" :class="b('img')">
<img :src="paddingImg"> <img :src="paddingImg">
<loading class="van-sku-img-uploader__uploading" type="spinner" color="black" /> <loading :class="b('uploading')" type="spinner" color="black" />
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,9 +1,9 @@
<template> <template>
<cell-group class="van-sku-messages"> <cell-group :class="b()">
<template v-for="(message, index) in messages"> <template v-for="(message, index) in messages">
<cell <cell
v-if="message.type === 'image'" v-if="message.type === 'image'"
class="van-sku-messages__image-cell" :class="b('image-cell')"
:label="$t('onePic')" :label="$t('onePic')"
:key="`${goodsId}-${index}`" :key="`${goodsId}-${index}`"
:required="message.required == '1'" :required="message.required == '1'"

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="van-sku-row"> <div :class="b()">
<div class="van-sku-row__title">{{ skuRow.k }}</div> <div :class="b('title')">{{ skuRow.k }}</div>
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -1,22 +1,8 @@
<template> <template>
<div <div :class="b({ disabled })" @click.stop="onClick">
class="van-slider" <div :class="b('bar')" :style="barStyle">
:class="{ 'van-slider--disabled': disabled }"
>
<div
class="van-slider__bar"
ref="bar"
:style="barStyle"
@click.stop="onSliderClicked"
>
<span <span
class="van-slider__finished-portion" :class="b('button')"
:style="finishedStyle"
/>
<span
class="van-slider__pivot"
ref="pivot"
:style="pivotStyle"
@touchstart="onTouchStart" @touchstart="onTouchStart"
@touchmove.prevent.stop="onTouchMove" @touchmove.prevent.stop="onTouchMove"
@touchend="onTouchEnd" @touchend="onTouchEnd"
@ -25,145 +11,90 @@
</div> </div>
</div> </div>
</template> </template>
<script>
<script>
import create from '../utils/create'; import create from '../utils/create';
import Touch from '../mixins/touch'; import Touch from '../mixins/touch';
const DEFAULT_COLOR = '#4b0';
const DEFAULT_BG = '#cacaca';
export default create({ export default create({
name: 'slider', name: 'slider',
mixins: [Touch], mixins: [Touch],
props: { props: {
disabled: Boolean,
max: { max: {
type: Number, type: Number,
default: 100 default: 100
}, },
min: { min: {
type: Number, type: Number,
default: 0 default: 0
}, },
step: {
type: Number,
default: 1
},
value: { value: {
type: Number, type: Number,
default: 0, default: 0
required: true
}, },
barHeight: {
disabled: Boolean,
pivotColor: {
type: String, type: String,
default: DEFAULT_COLOR default: '2px'
},
barColor: {
type: String,
default: DEFAULT_BG
},
loadedBarColor: {
type: String,
default: DEFAULT_COLOR
} }
}, },
data() {
return {
pivotOffset: 0
};
},
computed: { computed: {
sliderWidth() {
const rect = this.$refs.bar.getBoundingClientRect();
return rect['width'];
},
barStyle() { barStyle() {
return { return {
backgroundColor: this.barColor width: this.format(this.value) + '%',
}; height: this.barHeight
},
finishedStyle() {
return {
backgroundColor: this.loadedBarColor,
width: this.format(this.value) + '%'
};
},
pivotStyle() {
return {
backgroundColor: this.pivotColor,
left: this.format(this.value) + '%',
marginLeft: `-${this.pivotOffset}px`
}; };
} }
}, },
mounted() {
this.pivotOffset = parseInt(this.$refs.pivot.getBoundingClientRect().width / 2);
},
methods: { methods: {
onTouchStart(event) { onTouchStart(event) {
if (this.disabled) return; if (this.disabled) return;
this.draging = true;
this.touchStart(event); this.touchStart(event);
this.startValue = this.format(this.value); this.startValue = this.format(this.value);
}, },
onTouchMove(event) { onTouchMove(event) {
if (this.draging) { if (this.disabled) return;
this.touchMove(event); this.touchMove(event);
const diff = this.deltaX / this.sliderWidth * 100; const rect = this.$el.getBoundingClientRect();
this.newValue = this.startValue + diff; const diff = this.deltaX / rect.width * 100;
this.updateValue(this.newValue); this.updateValue(this.startValue + diff);
}
}, },
onTouchEnd() { onTouchEnd() {
if (this.draging) { if (this.disabled) return;
this.$nextTick(() => { this.updateValue(this.value, true);
this.draging = false;
this.updateValue(this.newValue, true);
});
}
}, },
onSliderClicked(e) { onClick(event) {
if (this.disabled || this.draging) return;
const sliderRect = this.$refs.bar.getBoundingClientRect();
const sliderOffset = sliderRect.left;
this.newValue = Math.round((e.clientX - sliderOffset) / this.sliderWidth * 100);
this.updateValue(this.newValue, true);
},
updateValue(value, isFinished) {
if (this.disabled) return; if (this.disabled) return;
const rect = this.$el.getBoundingClientRect();
const value = (event.clientX - rect.left) / rect.width * 100;
this.updateValue(value, true);
},
updateValue(value, end) {
value = this.format(value); value = this.format(value);
this.$emit('change', value);
this.$emit('input', value); this.$emit('input', value);
if (isFinished) { if (end) {
this.$emit('after-change', value); this.$emit('change', value);
} }
}, },
format(value) { format(value) {
return Math.round(this.range(value)); return (Math.round(Math.max(this.min, Math.min(value, this.max)) / this.step) * this.step);
},
range(value) {
return Math.max(this.min, Math.min(value, this.max));
} }
} }
}); });

View File

@ -1,13 +1,13 @@
<template> <template>
<div class="van-step van-hairline" :class="[`van-step--${$parent.direction}`, { [`van-step--${status}`]: status }]"> <div class="van-hairline" :class="b([$parent.direction, { [status]: status }])">
<div class="van-step__circle-container"> <div :class="b('title')" :style="titleStyle">
<i class="van-step__circle" v-if="status !== 'process'" />
<icon v-else name="checked" :style="{ color: $parent.activeColor }" />
</div>
<div class="van-step__title" :style="titleStyle">
<slot /> <slot />
</div> </div>
<div class="van-step__line" /> <div :class="b('circle-container')">
<i :class="b('circle')" v-if="status !== 'process'" />
<icon v-else name="checked" :style="{ color: $parent.activeColor }" />
</div>
<div :class="b('line')" />
</div> </div>
</template> </template>

View File

@ -1,20 +1,18 @@
<template> <template>
<div class="van-stepper" :class="{ 'van-stepper--disabled': disabled }"> <div :class="b({ disabled })">
<button <button
class="van-stepper__stepper van-stepper__minus" :class="b('minus', { disabled: minusDisabled })"
:class="{ 'van-stepper__minus--disabled': isMinusDisabled }"
@click="onChange('minus')" @click="onChange('minus')"
/> />
<input <input
type="number" type="number"
class="van-stepper__input" :class="b('input')"
:value="currentValue" :value="currentValue"
:disabled="disabled || disableInput" :disabled="disabled || disableInput"
@input="onInput" @input="onInput"
> >
<button <button
class="van-stepper__stepper van-stepper__plus" :class="b('plus', { disabled: plusDisabled })"
:class="{ 'van-stepper__plus--disabled': isPlusDisabled }"
@click="onChange('plus')" @click="onChange('plus')"
/> />
</div> </div>
@ -62,14 +60,14 @@ export default create({
}, },
computed: { computed: {
isMinusDisabled() { minusDisabled() {
const min = +this.min; const min = +this.min;
const step = +this.step; const step = +this.step;
const currentValue = +this.currentValue; const currentValue = +this.currentValue;
return min === currentValue || (currentValue - step) < min || this.disabled; return min === currentValue || (currentValue - step) < min || this.disabled;
}, },
isPlusDisabled() { plusDisabled() {
const max = +this.max; const max = +this.max;
const step = +this.step; const step = +this.step;
const currentValue = +this.currentValue; const currentValue = +this.currentValue;
@ -108,7 +106,7 @@ export default create({
}, },
onChange(type) { onChange(type) {
if ((this.isMinusDisabled && type === 'minus') || (this.isPlusDisabled && type === 'plus')) { if ((this.minusDisabled && type === 'minus') || (this.plusDisabled && type === 'plus')) {
this.$emit('overlimit', type); this.$emit('overlimit', type);
return; return;
} }

View File

@ -1,18 +1,18 @@
<template> <template>
<div class="van-steps" :class="`van-steps--${direction}`"> <div :class="b([direction])">
<div class="van-steps__status" v-if="title || description"> <div v-if="title || description" :class="b('status')">
<div class="van-steps__icon" v-if="icon || $slots.icon"> <div v-if="icon || $slots.icon" :class="b('icon')">
<slot name="icon"> <slot name="icon">
<icon :name="icon" :class="iconClass" /> <icon :name="icon" :class="iconClass" />
</slot> </slot>
</div> </div>
<div class="van-steps__message"> <div :class="b('message')">
<div class="van-steps__title" v-text="title" /> <div :class="b('title')" v-text="title" />
<div class="van-steps__desc van-ellipsis" v-text="description" /> <div :class="b('desc')" class="van-ellipsis" v-text="description" />
</div> </div>
<slot name="message-extra" /> <slot name="message-extra" />
</div> </div>
<div class="van-steps__items" :class="{ 'van-steps__items--alone': !title && !description }"> <div :class="b('items', { alone: !title && !description })">
<slot /> <slot />
</div> </div>
</div> </div>

View File

@ -1,15 +1,15 @@
<template> <template>
<div class="van-submit-bar"> <div :class="b()">
<div class="van-submit-bar__tip" v-show="tip || $slots.tip"> <div :class="b('tip')" v-show="tip || $slots.tip">
{{ tip }}<slot name="tip" /> {{ tip }}<slot name="tip" />
</div> </div>
<div class="van-submit-bar__bar"> <div :class="b('bar')">
<slot /> <slot />
<div class="van-submit-bar__price"> <div :class="b('price')">
<template v-if="hasPrice"> <template v-if="hasPrice">
<span>{{ label || $t('label') }}</span> <span>{{ label || $t('label') }}</span>
<span class="van-submit-bar__price-interger">{{ currency }}{{ priceInterger }}.</span> <span :class="b('price-interger')">{{ currency }}{{ priceInterger }}.</span>
<span class="van-submit-bar__price-decimal">{{ priceDecimal }}</span> <span :class="b('price-decimal')">{{ priceDecimal }}</span>
</template> </template>
</div> </div>
<van-button :type="buttonType" :disabled="disabled" :loading="loading" @click="onSubmit"> <van-button :type="buttonType" :disabled="disabled" :loading="loading" @click="onSubmit">

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="van-swipe-item" :style="style"> <div :class="b()" :style="style">
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -1,9 +1,9 @@
<template> <template>
<div class="van-swipe"> <div :class="b()">
<div <div
v-if="count > 1" v-if="count > 1"
:style="trackStyle" :style="trackStyle"
class="van-swipe__track" :class="b('track')"
@touchstart="onTouchStart" @touchstart="onTouchStart"
@touchmove="onTouchMove" @touchmove="onTouchMove"
@touchend="onTouchEnd" @touchend="onTouchEnd"
@ -12,11 +12,14 @@
> >
<slot /> <slot />
</div> </div>
<div v-else class="van-swipe__track"> <div v-else :class="b('track')">
<slot /> <slot />
</div> </div>
<div class="van-swipe__indicators" v-if="showIndicators && count > 1"> <div
<i v-for="index in count" :class="{ 'van-swipe__indicator--active': index - 1 === activeIndicator }" /> v-if="showIndicators && count > 1"
:class="b('indicators')"
>
<i v-for="index in count" :class="b('indicator', { active: index - 1 === activeIndicator })" />
</div> </div>
</div> </div>
</template> </template>

View File

@ -1,5 +1,5 @@
<template> <template>
<cell center :title="title" :border="border" class="van-switch-cell"> <cell center :title="title" :border="border" :class="b()">
<van-switch v-bind="$props" @input="$emit('input', $event)" /> <van-switch v-bind="$props" @input="$emit('input', $event)" />
</cell> </cell>
</template> </template>

View File

@ -1,15 +1,14 @@
<template> <template>
<div <div
class="van-switch" :class="b({
:class="[{ on: value,
'van-switch--on': value, disabled
'van-switch--disabled': disabled })"
}]"
:style="style" :style="style"
@click="onClick" @click="onClick"
> >
<div class="van-switch__node"> <div :class="b('node')">
<loading v-if="loading" class="van-switch__loading" /> <loading v-if="loading" :class="b('loading')" />
</div> </div>
</div> </div>
</template> </template>

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="van-tab__pane" :class="{ 'van-tab__pane--select': index === parent.curActive }"> <div :class="b('pane', { select: index === parent.curActive })">
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -1,12 +1,12 @@
<template> <template>
<div class="van-tabbar-item" :class="{ 'van-tabbar-item--active': active }" @click="onClick"> <div :class="b({ active })" @click="onClick">
<div class="van-tabbar-item__icon" :class="{ 'van-tabbar-item__icon-dot': dot }"> <div :class="b('icon', { dot })">
<slot name="icon" :active="active"> <slot name="icon" :active="active">
<icon v-if="icon" :name="icon" /> <icon v-if="icon" :name="icon" />
</slot> </slot>
<div v-if="isDef(info)" class="van-icon__info">{{ info }}</div> <div v-if="isDef(info)" class="van-icon__info">{{ info }}</div>
</div> </div>
<div class="van-tabbar-item__text"> <div :class="b('text')">
<slot :active="active"/> <slot :active="active"/>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="van-tabbar van-hairline--top-bottom" :class="{ 'van-tabbar--fixed': fixed }"> <div class="van-hairline--top-bottom" :class="b({ fixed })">
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -1,15 +1,14 @@
<template> <template>
<div class="van-tabs" :class="`van-tabs--${type}`"> <div :class="b([type])">
<div <div
ref="wrap" ref="wrap"
class="van-tabs__wrap" :class="[
:class="[`van-tabs__wrap--${position}`, { b('wrap', [position, { scrollable }]),
'van-tabs--scrollable': scrollable, { 'van-hairline--top-bottom': type === 'line' }
'van-hairline--top-bottom': type === 'line' ]"
}]"
> >
<div class="van-tabs__nav" :class="`van-tabs__nav--${type}`" ref="nav"> <div :class="b('nav', [type])" ref="nav">
<div v-if="type === 'line'" class="van-tabs__nav-bar" :style="navBarStyle" /> <div v-if="type === 'line'" :class="b('nav-bar')" :style="navBarStyle" />
<div <div
v-for="(tab, index) in tabs" v-for="(tab, index) in tabs"
ref="tabs" ref="tabs"
@ -25,7 +24,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="van-tabs__content" ref="content"> <div :class="b('content')" ref="content">
<slot /> <slot />
</div> </div>
</div> </div>

View File

@ -1,11 +1,11 @@
<template> <template>
<span <span
class="van-tag van-hairline--surround" class="van-hairline--surround"
:class="{ :class="b({
[`van-tag--${type}`]: type, mark,
'van-tag--plain': plain, plain,
'van-tag--mark': mark [type]: type
}" })"
> >
<slot /> <slot />
</span> </span>

View File

@ -1,6 +1,6 @@
<template> <template>
<transition name="van-fade"> <transition name="van-fade">
<div class="van-toast" :class="[`van-toast--${displayStyle}`, `van-toast--${position}`]" v-show="value"> <div v-show="value" :class="b([displayStyle, position])">
<!-- text only --> <!-- text only -->
<div v-if="displayStyle === 'text'">{{ message }}</div> <div v-if="displayStyle === 'text'">{{ message }}</div>
<div v-if="displayStyle === 'html'" v-html="message" /> <div v-if="displayStyle === 'html'" v-html="message" />
@ -8,8 +8,8 @@
<!-- with icon --> <!-- with icon -->
<template v-if="displayStyle === 'default'"> <template v-if="displayStyle === 'default'">
<loading v-if="type === 'loading'" color="white" /> <loading v-if="type === 'loading'" color="white" />
<icon v-else class="van-toast__icon" :name="type" /> <icon v-else :class="b('icon')" :name="type" />
<div v-if="hasMessage" class="van-toast__text">{{ message }}</div> <div v-if="hasMessage" :class="b('text')">{{ message }}</div>
</template> </template>
</div> </div>
</transition> </transition>

View File

@ -1,26 +1,26 @@
<template> <template>
<div class="van-tree-select" :style="{ height: mainHeight + 'px' }"> <div :class="b()" :style="{ height: mainHeight + 'px' }">
<div class="van-tree-select__nav"> <div :class="b('nav')">
<div <div
v-for="(item, index) in items" v-for="(item, index) in items"
class="van-tree-select__nitem van-ellipsis" class="van-ellipsis"
:class="{ 'van-tree-select__nitem--active': mainActiveIndex === index }" :class="b('nitem', { active: mainActiveIndex === index })"
@click="$emit('navclick', index)"> @click="$emit('navclick', index)">
{{ item.text }} {{ item.text }}
</div> </div>
</div> </div>
<div class="van-tree-select__content" :style="{ height: itemHeight + 'px' }"> <div :class="b('content')" :style="{ height: itemHeight + 'px' }">
<div <div
v-for="item in subItems" v-for="item in subItems"
:key="item.id" :key="item.id"
class="van-tree-select__item van-ellipsis" class="van-ellipsis"
:class="{ 'van-tree-select__item--active': activeId === item.id }" :class="b('item', { active: activeId === item.id })"
@click="onItemSelect(item)"> @click="onItemSelect(item)">
{{ item.text }} {{ item.text }}
<icon <icon
v-if="activeId === item.id" v-if="activeId === item.id"
name="success" name="success"
class="van-tree-select__selected" :class="b('selected')"
/> />
</div> </div>
</div> </div>

View File

@ -1,11 +1,12 @@
<template> <template>
<div class="van-uploader"> <div :class="b()">
<slot /> <slot />
<input <input
v-bind="$attrs"
ref="input" ref="input"
type="file" type="file"
class="van-uploader__input" :class="b('input')"
v-bind="$attrs" :accept="accept"
:disabled="disabled" :disabled="disabled"
@change="onChange" @change="onChange"
> >
@ -24,6 +25,10 @@ export default create({
disabled: Boolean, disabled: Boolean,
beforeRead: Function, beforeRead: Function,
afterRead: Function, afterRead: Function,
accept: {
type: String,
default: 'image/*'
},
resultType: { resultType: {
type: String, type: String,
default: 'dataUrl' default: 'dataUrl'

View File

@ -11,7 +11,7 @@
&__area { &__area {
.van-cell__title { .van-cell__title {
width: 90px; max-width: 90px;
} }
.van-cell__value { .van-cell__value {

View File

@ -1,7 +1,6 @@
@import './common/var.css'; @import './common/var.css';
.van-cell { .van-cell {
width: 100%;
display: flex; display: flex;
padding: 10px 15px; padding: 10px 15px;
box-sizing: border-box; box-sizing: border-box;
@ -24,31 +23,38 @@
background-color: $white; background-color: $white;
} }
&__left-icon {
font-size: 16px;
line-height: 1.5;
margin-right: 5px;
}
&__label { &__label {
font-size: 12px; font-size: 12px;
line-height: 1.2; line-height: 1.2;
color: $gray-darker; color: $gray-darker;
} }
&__title,
&__value { &__value {
flex: 1; flex: 1;
}
&__value {
overflow: hidden;
text-align: right; text-align: right;
vertical-align: middle; vertical-align: middle;
overflow: hidden;
&--alone { &--alone {
text-align: left; text-align: left;
} }
&--link {
padding-right: 15px;
} }
&__left-icon {
font-size: 16px;
line-height: 24px;
margin-right: 5px;
}
&__right-icon {
color: $gray-dark;
font-size: 12px;
line-height: 24px;
margin-left: 5px;
} }
&--clickable { &--clickable {
@ -72,13 +78,4 @@
&--center { &--center {
align-items: center; align-items: center;
} }
&__right-icon {
position: absolute;
top: 50%;
right: 15px;
transform: translateY(-50%);
color: $gray-dark;
font-size: 12px;
}
} }

View File

@ -17,7 +17,7 @@
box-sizing: border-box; box-sizing: border-box;
} }
&__filed { &__field {
margin: 10px 0; margin: 10px 0;
padding: 4px 10px 4px 25px; padding: 4px 10px 4px 25px;
@ -77,7 +77,7 @@
} }
} }
&--with-exchange { &__list--with-exchange {
padding-top: 60px; padding-top: 60px;
} }

View File

@ -36,7 +36,7 @@
&__footer { &__footer {
overflow: hidden; overflow: hidden;
&.is-twobtn { &--buttons {
display: flex; display: flex;
.van-button { .van-button {

View File

@ -2,7 +2,7 @@
.van-field { .van-field {
.van-cell__title { .van-cell__title {
min-width: 90px; max-width: 90px;
} }
.van-cell__value { .van-cell__value {

View File

@ -7,7 +7,7 @@
display: flex; display: flex;
position: fixed; position: fixed;
&__big-btn { &-big-btn {
flex: 1; flex: 1;
padding: 0; padding: 0;
@ -16,7 +16,7 @@
} }
} }
&__mini-btn { &-mini-btn {
color: $gray-darker; color: $gray-darker;
display: flex; display: flex;
height: 50px; height: 50px;
@ -40,7 +40,7 @@
background-color: $active-color; background-color: $active-color;
} }
&-icon { &__icon {
font-size: 20px; font-size: 20px;
margin-bottom: 5px; margin-bottom: 5px;
} }

View File

@ -34,7 +34,7 @@
line-height: 1; line-height: 1;
} }
&__content-wrap { &__wrap {
flex: 1; flex: 1;
height: 18px; height: 18px;
overflow: hidden; overflow: hidden;

View File

@ -28,31 +28,27 @@
&:last-child::after { &:last-child::after {
border-right-width: 1px; border-right-width: 1px;
} }
}
&__prev, &--disabled,
&__next { &--disabled:active {
&.van-pagination__item {
padding: 0 5px;
}
}
&__page {
flex-grow: 0;
&.van-pagination--active {
background-color: $blue;
color: $white;
}
}
&--disabled {
&.van-pagination__item {
background-color: $background-color; background-color: $background-color;
color: $gray-darker; color: $gray-darker;
opacity: 0.6; opacity: 0.6;
} }
&--active {
color: $white;
background-color: $blue;
}
}
&__prev,
&__next {
padding: 0 5px;
}
&__page {
flex-grow: 0;
} }
&__page-desc { &__page-desc {
@ -60,15 +56,13 @@
height: 40px; height: 40px;
color: $gray-darker; color: $gray-darker;
} }
}
.van-pagination-simple {
&--simple {
.van-pagination__prev, .van-pagination__prev,
.van-pagination__next { .van-pagination__next {
&::after {
&.van-pagination__item::after {
border-width: 1px; border-width: 1px;
} }
} }
} }
}

View File

@ -4,26 +4,10 @@
background: $white; background: $white;
&__header { &__header {
padding: 10px 15px; .van-cell__value {
}
&__title {
font-size: 14px;
color: $text-color;
}
&__desc {
font-size: 12px;
color: $gray-darker;
}
&__status {
font-size: 14px;
position: absolute;
top: 10px;
right: 15px;
color: $red; color: $red;
} }
}
&__footer { &__footer {
padding: 10px 15px; padding: 10px 15px;

View File

@ -5,6 +5,7 @@
user-select: none; user-select: none;
position: relative; position: relative;
background-color: $white; background-color: $white;
-webkit-text-size-adjust: 100%; /* avoid iOS text size adjust */
&__toolbar { &__toolbar {
display: flex; display: flex;
@ -64,17 +65,17 @@
font-size: 17px; font-size: 17px;
text-align: center; text-align: center;
li { &__item {
padding: 0 5px; padding: 0 5px;
color: $gray-darker; color: $gray-darker;
}
li&--selected { &--selected {
color: $black; color: $black;
} }
li&--disabled { &--disabled {
opacity: .3; opacity: .3;
} }
} }
} }
}

View File

@ -10,7 +10,7 @@
padding-right: 0; padding-right: 0;
} }
&__input-wrap { &__wrap {
position: relative; position: relative;
flex: 1; flex: 1;
height: 34px; height: 34px;
@ -49,7 +49,7 @@
letter-spacing: 1px; letter-spacing: 1px;
} }
&__action-text { &__cancel {
padding: 0 10px; padding: 0 10px;
color: $green; color: $green;

View File

@ -164,7 +164,7 @@
&__image-cell { &__image-cell {
.van-cell__title { .van-cell__title {
width: 90px; max-width: 90px;
} }
.van-cell__value { .van-cell__value {
text-align: left; text-align: left;

View File

@ -1,41 +1,29 @@
@import './common/var.css'; @import './common/var.css';
$c-slider-background: #cacaca;
$c-pivot-border: #fff;
.van-slider { .van-slider {
&--disabled { position: relative;
opacity: .3; border-radius: 999px;
.van-slider__pivot { background-color: $border-color;
cursor: not-allowed;
}
}
&__bar { &__bar {
position: relative; position: relative;
margin: 0 15px; border-radius: inherit;
height: 4px; background-color: $blue;
border-radius: 5px;
background: $c-slider-background;
} }
&__loaded-portion, &__button {
&__finished-portion {
border-radius: 5px;
height: 100%;
position: absolute;
left: 0;
}
&__pivot {
position: absolute; position: absolute;
top: 50%; top: 50%;
width: 16px; right: 0;
height: 16px; width: 20px;
border: 3px solid $c-pivot-border; height: 20px;
box-shadow: 0 1px 4px;
border-radius: 50%; border-radius: 50%;
background-color: $c-slider-background; background-color: $white;
transform: translate3d(0, -50%, 0); transform: translate3d(50%, -50%, 0);
box-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}
&--disabled {
opacity: .3;
} }
} }

View File

@ -11,7 +11,8 @@
} }
} }
&__stepper { &__minus,
&__plus {
width: 40px; width: 40px;
height: 30px; height: 30px;
box-sizing: border-box; box-sizing: border-box;
@ -42,10 +43,7 @@
bottom: 0; bottom: 0;
background-color: #6c6c6c; background-color: #6c6c6c;
} }
}
&__minus,
&__plus {
&:active { &:active {
background-color: $active-color; background-color: $active-color;
} }

View File

@ -22,23 +22,22 @@ $van-swipe-indicator: 6px;
position: absolute; position: absolute;
height: $van-swipe-indicator; height: $van-swipe-indicator;
transform: translate3d(-50%, 0, 0); transform: translate3d(-50%, 0, 0);
}
> i { &__indicator {
border-radius: 100%; border-radius: 100%;
vertical-align: top; vertical-align: top;
display: inline-block; display: inline-block;
background-color: $gray-dark; background-color: $gray-dark;
width: $van-swipe-indicator; width: $van-swipe-indicator;
height: $van-swipe-indicator; height: $van-swipe-indicator;
&:not(:last-child) { &:not(:last-child) {
margin-right: $van-swipe-indicator; margin-right: $van-swipe-indicator;
} }
}
.van-swipe__indicator {
&--active { &--active {
background-color: $orange; background-color: $orange;
} }
} }
} }
}

View File

@ -22,6 +22,22 @@ $van-tabs-card-height: 30px;
top: auto; top: auto;
bottom: 0; bottom: 0;
} }
&--scrollable {
.van-tab {
flex: 0 0 22%;
}
.van-tabs__nav {
overflow: hidden;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
&::-webkit-scrollbar {
display: none;
}
}
}
} }
&__nav { &__nav {
@ -69,22 +85,6 @@ $van-tabs-card-height: 30px;
background-color: $red; background-color: $red;
} }
&--scrollable {
.van-tab {
flex: 0 0 22%;
}
.van-tabs__nav {
overflow: hidden;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
&::-webkit-scrollbar {
display: none;
}
}
}
&--line { &--line {
padding-top: $van-tabs-line-height; padding-top: $van-tabs-line-height;

View File

@ -31,7 +31,7 @@
display: block; display: block;
} }
&-dot { &--dot {
&::after { &::after {
top: 0; top: 0;
right: -8px; right: -8px;

View File

@ -165,7 +165,7 @@ describe('Checkbox', () => {
expect(wrapper.hasClass('van-checkbox')).to.be.true; expect(wrapper.hasClass('van-checkbox')).to.be.true;
const eventStub = sinon.stub(wrapper.vm, '$emit'); const eventStub = sinon.stub(wrapper.vm, '$emit');
const checkboxLabel = wrapper.find('.van-checkbox__label')[0]; const checkboxLabel = wrapper.find('.van-checkbox__icon')[0];
checkboxLabel.trigger('click'); checkboxLabel.trigger('click');
wrapper.update(); wrapper.update();
@ -189,7 +189,7 @@ describe('Checkbox', () => {
expect(wrapper.vm.currentValue).to.be.false; expect(wrapper.vm.currentValue).to.be.false;
expect(wrapper.vm.isDisabled).to.be.true; expect(wrapper.vm.isDisabled).to.be.true;
const checkboxLabel = wrapper.find('.van-checkbox__label')[0]; const checkboxLabel = wrapper.find('.van-checkbox__icon')[0];
checkboxLabel.trigger('click'); checkboxLabel.trigger('click');
expect(wrapper.vm.currentValue).to.be.false; expect(wrapper.vm.currentValue).to.be.false;
@ -206,7 +206,7 @@ describe('Checkbox', () => {
expect(wrapper.hasClass('van-checkbox')).to.be.true; expect(wrapper.hasClass('van-checkbox')).to.be.true;
expect(wrapper.vm.currentValue).to.be.false; expect(wrapper.vm.currentValue).to.be.false;
const checkboxLabel = wrapper.find('.van-checkbox__label')[0]; const checkboxLabel = wrapper.find('.van-checkbox__icon')[0];
checkboxLabel.trigger('click'); checkboxLabel.trigger('click');
expect(wrapper.vm.currentValue).to.be.false; expect(wrapper.vm.currentValue).to.be.false;

View File

@ -16,8 +16,8 @@ describe('GoodsAction', () => {
DOMChecker(wrapper, { DOMChecker(wrapper, {
count: { count: {
'.van-goods-action__mini-btn': 2, '.van-goods-action-mini-btn': 2,
'.van-goods-action__big-btn': 2, '.van-goods-action-big-btn': 2,
'.van-icon-chat': 1 '.van-icon-chat': 1
} }
}); });

Some files were not shown because too many files have changed in this diff Show More