diff --git a/docs/markdown/changelog.en-US.md b/docs/markdown/changelog.en-US.md index 62c8d159f..212c991c0 100644 --- a/docs/markdown/changelog.en-US.md +++ b/docs/markdown/changelog.en-US.md @@ -34,6 +34,15 @@ Upgrading the style of business components: - fix NumberKeyboard should not trigger blur event when hidden [\#5110](https://github.com/youzan/vant/pull/5110) +### [v2.2.16](https://github.com/youzan/vant/tree/v2.2.16) +`2019-12-03` + +**Features** + +- Stepper: add disable-plus props [\#5180](https://github.com/youzan/vant/pull/5180) +- Stepper: add disable-minus props [\#5180](https://github.com/youzan/vant/pull/5180) + + ### [v2.2.15](https://github.com/youzan/vant/tree/v2.2.15) `2019-11-28` diff --git a/docs/markdown/changelog.zh-CN.md b/docs/markdown/changelog.zh-CN.md index 3203624a6..b998447d2 100644 --- a/docs/markdown/changelog.zh-CN.md +++ b/docs/markdown/changelog.zh-CN.md @@ -45,6 +45,15 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。 - 修复 NumberKeyboard 在隐藏状态下也会触发 blur 事件的问题 [\#5110](https://github.com/youzan/vant/pull/5110) +### [v2.2.16](https://github.com/youzan/vant/tree/v2.2.16) +`2019-12-03` + +**Features** + +- Stepper: 新增 disable-plus 属性 [\#5180](https://github.com/youzan/vant/pull/5180) +- Stepper: 新增 disable-minus 属性 [\#5180](https://github.com/youzan/vant/pull/5180) + + ### [v2.2.15](https://github.com/youzan/vant/tree/v2.2.15) `2019-11-28` diff --git a/src/action-sheet/index.tsx b/src/action-sheet/index.tsx index 2f395e88f..a392119eb 100644 --- a/src/action-sheet/index.tsx +++ b/src/action-sheet/index.tsx @@ -53,7 +53,11 @@ function ActionSheet( return (
{title} - +
); } @@ -99,6 +103,7 @@ function ActionSheet( return ( ); diff --git a/src/action-sheet/test/__snapshots__/index.spec.js.snap b/src/action-sheet/test/__snapshots__/index.spec.js.snap index ac00f117a..2632f09b2 100644 --- a/src/action-sheet/test/__snapshots__/index.spec.js.snap +++ b/src/action-sheet/test/__snapshots__/index.spec.js.snap @@ -1,9 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`callback events 1`] = ` -
+ `; exports[`close-icon prop 1`] = ` @@ -13,15 +13,15 @@ exports[`close-icon prop 1`] = ` `; -exports[`color option 1`] = `
`; +exports[`color option 1`] = `
`; exports[`description prop 1`] = `
-
This is a description
+
This is a description
`; -exports[`disable lazy-render 1`] = ``; +exports[`disable lazy-render 1`] = ``; exports[`render title and default slot 1`] = `
@@ -31,4 +31,4 @@ exports[`render title and default slot 1`] = `
`; -exports[`round prop 1`] = `
`; +exports[`round prop 1`] = `
`; diff --git a/src/area/test/__snapshots__/demo.spec.js.snap b/src/area/test/__snapshots__/demo.spec.js.snap index 800cd7ce5..17f03ba59 100644 --- a/src/area/test/__snapshots__/demo.spec.js.snap +++ b/src/area/test/__snapshots__/demo.spec.js.snap @@ -4,7 +4,7 @@ exports[`renders demo correctly 1`] = `
-
+
@@ -79,7 +79,7 @@ exports[`renders demo correctly 1`] = `
-
+
@@ -159,8 +159,8 @@ exports[`renders demo correctly 1`] = `
-
-
标题
+
+
标题
@@ -216,8 +216,8 @@ exports[`renders demo correctly 1`] = `
-
-
标题
+
+
标题
diff --git a/src/area/test/__snapshots__/index.spec.js.snap b/src/area/test/__snapshots__/index.spec.js.snap index 1edcbe9d3..b95110eb6 100644 --- a/src/area/test/__snapshots__/index.spec.js.snap +++ b/src/area/test/__snapshots__/index.spec.js.snap @@ -2,7 +2,7 @@ exports[`change option 1`] = `
-
+
@@ -32,7 +32,7 @@ exports[`change option 1`] = ` exports[`change option 2`] = `
-
+
@@ -62,7 +62,7 @@ exports[`change option 2`] = ` exports[`change option 3`] = `
-
+
@@ -92,7 +92,7 @@ exports[`change option 3`] = ` exports[`columns-num prop 1`] = `
-
+
@@ -116,7 +116,7 @@ exports[`columns-num prop 1`] = ` exports[`reset method 1`] = `
-
+
@@ -145,7 +145,7 @@ exports[`reset method 1`] = ` exports[`reset method 2`] = `
-
+
@@ -175,7 +175,7 @@ exports[`reset method 2`] = ` exports[`watch areaList & code 1`] = `
-
+
@@ -205,7 +205,7 @@ exports[`watch areaList & code 1`] = ` exports[`watch areaList & code 2`] = `
-
+
@@ -235,7 +235,7 @@ exports[`watch areaList & code 2`] = ` exports[`watch areaList & code 3`] = `
-
+
diff --git a/src/coupon-list/README.md b/src/coupon-list/README.md index cf8917223..7704d3791 100644 --- a/src/coupon-list/README.md +++ b/src/coupon-list/README.md @@ -99,6 +99,7 @@ export default { | input-placeholder | Input placeholder | *string* | `Coupon code` | - | | currency | Currency symbol | *string* | `¥` | - | | empty-image | Placeholder image when list is empty | *string* | `https://img.yzcdn.cn/vant/coupon-empty.png` | - | +| show-count | Whether to show coupon count in tab title | *boolean* | `true` | - | ### CouponList Events diff --git a/src/coupon-list/README.zh-CN.md b/src/coupon-list/README.zh-CN.md index fbe67b782..f8dd8bc9b 100644 --- a/src/coupon-list/README.zh-CN.md +++ b/src/coupon-list/README.zh-CN.md @@ -101,6 +101,7 @@ export default { | show-exchange-bar | 是否展示兑换栏 | *boolean* | `true` | - | | currency | 货币符号 | *string* | `¥` | - | | empty-image | 列表为空时的占位图 | *string* | `https://img.yzcdn.cn/vant/coupon-empty.png` | 2.1.0 | +| show-count | 是否展示可用 / 不可用数量 | *boolean* | `true` | - | ### CouponList Events diff --git a/src/coupon-list/demo/index.vue b/src/coupon-list/demo/index.vue index 0bcceb5d9..2d9e0d96b 100644 --- a/src/coupon-list/demo/index.vue +++ b/src/coupon-list/demo/index.vue @@ -15,6 +15,7 @@ :coupons="coupons" :chosen-coupon="chosenCoupon" :disabled-coupons="disabledCoupons" + :show-count="false" @change="onChange" @exchange="onExchange" /> diff --git a/src/coupon-list/index.js b/src/coupon-list/index.js index 138fe8d37..97ed343e2 100644 --- a/src/coupon-list/index.js +++ b/src/coupon-list/index.js @@ -50,6 +50,10 @@ export default createComponent({ type: Boolean, default: true }, + showCount: { + type: Boolean, + default: true + }, currency: { type: String, default: '¥' @@ -139,7 +143,7 @@ export default createComponent({ genExchangeButton() { return (
+
-
+
- - + +
@@ -29,7 +29,7 @@ exports[`empty-image prop 1`] = `
-
+
`; @@ -54,15 +54,15 @@ exports[`render coupon list 1`] = `
-
+
-
+
- - + +
@@ -73,11 +73,15 @@ exports[`render coupon list 1`] = `

-

无使用门槛

+

无使用门槛

-

-

有效期:2017.03.10 - 2017.12.30

+

+

2017.03.10 - 2017.12.30

+
@@ -85,12 +89,12 @@ exports[`render coupon list 1`] = `

¥ 1.5

-

无使用门槛

+

无使用门槛

-

name

-

有效期:2017.03.10 - 2017.12.30

- @@ -140,11 +156,15 @@ exports[`render coupon list 1`] = `

9折

-

满0.5元可用

+

满0.5元可用

-

name

-

有效期:2017.03.10 - 2017.12.30

+

name

+

2017.03.10 - 2017.12.30

+
@@ -154,7 +174,7 @@ exports[`render coupon list 1`] = `
-
+
`; @@ -163,11 +183,11 @@ exports[`render disabled coupon 1`] = `

¥ 1.5

-

无使用门槛

+

无使用门槛

-

name

-

有效期:2017.03.10 - 2017.12.30

+

name

+

2017.03.10 - 2017.12.30

reason

@@ -179,15 +199,15 @@ exports[`render empty coupon list 1`] = `
-
+
-
+
- - + +
@@ -207,6 +227,6 @@ exports[`render empty coupon list 1`] = `
-
+
`; diff --git a/src/coupon/index.js b/src/coupon/index.js index 9d07b560e..f8fc8081f 100644 --- a/src/coupon/index.js +++ b/src/coupon/index.js @@ -34,7 +34,7 @@ export default createComponent({ computed: { validPeriod() { const { startAt, endAt } = this.coupon; - return `${t('valid')}:${getDate(startAt)} - ${getDate(endAt)}`; + return `${getDate(startAt)} - ${getDate(endAt)}`; }, faceAmount() { @@ -70,13 +70,13 @@ export default createComponent({

-

{this.coupon.condition || this.conditionMessage}

+

{this.coupon.condition || this.conditionMessage}

-

{coupon.name}

-

{this.validPeriod}

- {this.chosen && ( - +

{coupon.name}

+

{this.validPeriod}

+ {!this.disabled && ( + )}
diff --git a/src/coupon/index.less b/src/coupon/index.less index 63441440b..5b08170af 100644 --- a/src/coupon/index.less +++ b/src/coupon/index.less @@ -14,45 +14,36 @@ &__content { display: flex; + align-items: center; box-sizing: border-box; - height: @coupon-content-height; + min-height: @coupon-content-height; padding: @coupon-content-padding; - } - - p, - h2 { - margin: 0; - - .ellipsis(); - } - - h2 { - height: 34px; - font-weight: @font-weight-bold; - line-height: 34px; - } - - p { - color: @gray-6; - font-size: @font-size-sm; - line-height: 16px; + color: @gray-8; } &__head { position: relative; min-width: @coupon-head-width; - padding-right: @padding-xs; + padding: 0 @padding-xs; + color: @coupon-amount-color; + text-align: center; + } - p { - white-space: pre-wrap; - } + &__amount, + &__condition, + &__name, + &__valid { + .ellipsis(); } &__amount { - color: @coupon-amount-color; + margin-bottom: 6px; + font-weight: @font-weight-bold; font-size: @coupon-amount-font-size; + .ellipsis(); span { + font-weight: normal; font-size: @coupon-currency-font-size; &:not(:empty) { @@ -61,6 +52,12 @@ } } + &__condition { + font-size: @font-size-sm; + line-height: 16px; + white-space: pre-wrap; + } + &__body { position: relative; flex: 1; @@ -68,17 +65,26 @@ } &__name { + margin-bottom: 10px; + font-weight: bold; font-size: @coupon-name-font-size; + line-height: 20px; + } + + &__valid { + font-size: @font-size-sm; } &__corner { position: absolute; - top: @padding-md; + top: 0; right: @padding-md; + bottom: 0; } &__description { padding: @coupon-description-padding; + font-size: @font-size-sm; background-color: @coupon-description-background-color; border-top: 1px dashed @coupon-description-border-color; } @@ -92,10 +98,8 @@ height: @coupon-content-height - 10px; } - p, - h2, - span { - color: @coupon-disabled-text-color; + .van-coupon__head { + color: inherit; } } } diff --git a/src/datetime-picker/test/__snapshots__/date-picker.spec.js.snap b/src/datetime-picker/test/__snapshots__/date-picker.spec.js.snap index 1c224ee23..021a425f5 100644 --- a/src/datetime-picker/test/__snapshots__/date-picker.spec.js.snap +++ b/src/datetime-picker/test/__snapshots__/date-picker.spec.js.snap @@ -2,7 +2,7 @@ exports[`filter prop 1`] = `
-
+
@@ -61,7 +61,7 @@ exports[`filter prop 1`] = ` exports[`formatter prop 1`] = `
-
+
diff --git a/src/datetime-picker/test/__snapshots__/datetime-picker.spec.js.snap b/src/datetime-picker/test/__snapshots__/datetime-picker.spec.js.snap index 7a0e7e0d6..72bd141c5 100644 --- a/src/datetime-picker/test/__snapshots__/datetime-picker.spec.js.snap +++ b/src/datetime-picker/test/__snapshots__/datetime-picker.spec.js.snap @@ -2,7 +2,7 @@ exports[`time type 1`] = `
-
+
diff --git a/src/datetime-picker/test/__snapshots__/demo.spec.js.snap b/src/datetime-picker/test/__snapshots__/demo.spec.js.snap index c622030fa..859d83682 100644 --- a/src/datetime-picker/test/__snapshots__/demo.spec.js.snap +++ b/src/datetime-picker/test/__snapshots__/demo.spec.js.snap @@ -4,7 +4,7 @@ exports[`renders demo correctly 1`] = `
-
+
@@ -164,7 +164,7 @@ exports[`renders demo correctly 1`] = `
-
+
@@ -242,7 +242,7 @@ exports[`renders demo correctly 1`] = `
-
+
@@ -285,7 +285,7 @@ exports[`renders demo correctly 1`] = `
-
+
@@ -375,7 +375,7 @@ exports[`renders demo correctly 1`] = `
-
+
diff --git a/src/datetime-picker/test/__snapshots__/time-picker.spec.js.snap b/src/datetime-picker/test/__snapshots__/time-picker.spec.js.snap index 2a5e847cb..6d7e9887f 100644 --- a/src/datetime-picker/test/__snapshots__/time-picker.spec.js.snap +++ b/src/datetime-picker/test/__snapshots__/time-picker.spec.js.snap @@ -2,7 +2,7 @@ exports[`filter prop 1`] = `
-
+
@@ -33,7 +33,7 @@ exports[`filter prop 1`] = ` exports[`format initial value 1`] = `
-
+
@@ -57,7 +57,7 @@ exports[`format initial value 1`] = ` exports[`formatter prop 1`] = `
-
+
@@ -88,7 +88,7 @@ exports[`formatter prop 1`] = ` exports[`max-hour & max-minute 1`] = `
-
+
diff --git a/src/icon/README.md b/src/icon/README.md index fcf3d291c..c25a1e656 100644 --- a/src/icon/README.md +++ b/src/icon/README.md @@ -22,12 +22,34 @@ Use `name` prop to set icon name or icon URL ### Show Info +Use `dot` prop, a small red dot will be displayed in the upper right corner of the icon. + +Use `info` prop, the info will be displayed in the upper right corner of the icon. + ```html ``` +### Icon Color + +Use `color` prop to set icon color + +```html + + +``` + +### Icon Size + +Use `size` prop to set icon size + +```html + + +``` + ### Use local font file Icon uses font file in `yzcdn.cn` by default,if you want to use the local font file,please import the following css file. diff --git a/src/icon/README.zh-CN.md b/src/icon/README.zh-CN.md index 33e4e2071..168f0b41b 100644 --- a/src/icon/README.zh-CN.md +++ b/src/icon/README.zh-CN.md @@ -34,6 +34,25 @@ Vue.use(Icon); ``` + +### 图标颜色 + +`Icon`的`color`属性用来设置图标的颜色 + +```html + + +``` + +### 图标大小 + +`Icon`的`size`属性用来设置图标的尺寸大小 + +```html + + +``` + ### 使用本地字体文件 Icon 组件默认引用有赞 CDN 提供的字体文件,并通过网络下载。如果需要在项目中使用本地字体文件,请引入下面的 CSS 文件,并在项目中配置`url-loader` diff --git a/src/icon/demo/index.vue b/src/icon/demo/index.vue index 846d1d9c4..6e5086ea8 100644 --- a/src/icon/demo/index.vue +++ b/src/icon/demo/index.vue @@ -21,6 +21,49 @@ {{ icon }} + + + + + + {{ demoIcon }} + + + + {{ demoIcon }} + + + + + + {{ demoIcon }} + + + + {{ demoIcon }} + + + + + + {{ demoIcon }} + + + + {{ demoIcon }} + + + + + + {{ demoIcon }} + + + + {{ demoIcon }} + + + @@ -61,7 +104,12 @@ export default { basic: '基础图标', copied: '复制成功', outline: '线框风格', - filled: '实底风格' + filled: '实底风格', + demo: '用法示例', + dot: '图标右上角小红点', + message: '图标右上角徽标的内容', + color: '图标颜色', + size: '图标大小' }, 'en-US': { title: 'Icon List', @@ -69,7 +117,12 @@ export default { basic: 'Basic', copied: 'Copied', outline: 'Outline', - filled: 'Filled' + filled: 'Filled', + demo: 'Demo', + dot: 'Show Red Dot', + message: 'Show Info', + color: 'Icon Color', + size: 'Icon Size' } }, @@ -77,13 +130,27 @@ export default { this.BLUE = BLUE; this.icons = icons; return { - tab: 0 + tab: 0, + demoIcon: 'location-o' }; }, methods: { - copy(icon) { - const tag = ``; + copy(icon, option = {}) { + let tag = ``; copyToClipboard(tag); this.$notify({ diff --git a/src/locale/lang/en-US.ts b/src/locale/lang/en-US.ts index fa0f096f7..9b9b4f1ec 100644 --- a/src/locale/lang/en-US.ts +++ b/src/locale/lang/en-US.ts @@ -29,7 +29,6 @@ export default { label: 'Total:' }, vanCoupon: { - valid: 'Valid', unlimited: 'Unlimited', discount: (discount: number) => `${discount * 10}% off`, condition: (condition: number) => `At least ${condition}` diff --git a/src/locale/lang/es-ES.ts b/src/locale/lang/es-ES.ts index 9f5bf0c8d..1f889836e 100644 --- a/src/locale/lang/es-ES.ts +++ b/src/locale/lang/es-ES.ts @@ -29,7 +29,6 @@ export default { label: 'Total:' }, vanCoupon: { - valid: 'Valido', unlimited: 'Ilimitado', discount: (discount: number) => `${discount * 10}% de descuento`, condition: (condition: number) => `Al menos ${condition}` diff --git a/src/locale/lang/tr-TR.ts b/src/locale/lang/tr-TR.ts index 09b29a7f1..815bc4660 100644 --- a/src/locale/lang/tr-TR.ts +++ b/src/locale/lang/tr-TR.ts @@ -29,7 +29,6 @@ export default { label: 'Toplam:' }, vanCoupon: { - valid: 'Geçerli', unlimited: 'Sınırsız', discount: (discount: number) => `%${discount * 10} indirim`, condition: (condition: number) => `En az ${condition}` diff --git a/src/locale/lang/zh-CN.ts b/src/locale/lang/zh-CN.ts index 08b4d5779..15b555f75 100644 --- a/src/locale/lang/zh-CN.ts +++ b/src/locale/lang/zh-CN.ts @@ -29,7 +29,6 @@ export default { label: '合计:' }, vanCoupon: { - valid: '有效期', unlimited: '无使用门槛', discount: (discount: number) => `${discount}折`, condition: (condition: number) => `满${condition}元可用` @@ -42,9 +41,9 @@ export default { vanCouponList: { empty: '暂无优惠券', exchange: '兑换', - close: '不使用优惠', - enable: '可使用优惠券', - disabled: '不可使用优惠券', + close: '不使用优惠券', + enable: '可用', + disabled: '不可用', placeholder: '请输入优惠码' }, vanAddressEdit: { diff --git a/src/locale/lang/zh-HK.ts b/src/locale/lang/zh-HK.ts index 094ced3e5..8da5efd65 100644 --- a/src/locale/lang/zh-HK.ts +++ b/src/locale/lang/zh-HK.ts @@ -29,7 +29,6 @@ export default { label: '合計:' }, vanCoupon: { - valid: '有效期', unlimited: '無使用門檻', discount: (discount: number) => `${discount}折`, condition: (condition: number) => `滿${condition}元可用` diff --git a/src/locale/lang/zh-TW.ts b/src/locale/lang/zh-TW.ts index f33dacd8c..3efc98a0b 100644 --- a/src/locale/lang/zh-TW.ts +++ b/src/locale/lang/zh-TW.ts @@ -29,7 +29,6 @@ export default { label: '合計:' }, vanCoupon: { - valid: '有效期限', unlimited: '無使用門檻', discount: (discount: number) => `${discount}折`, condition: (condition: number) => `滿${condition}元可用` diff --git a/src/picker/index.js b/src/picker/index.js index 02bf60e97..b04d7fc7d 100644 --- a/src/picker/index.js +++ b/src/picker/index.js @@ -63,7 +63,12 @@ export default createComponent({ onChange(columnIndex) { if (this.simple) { - this.$emit('change', this, this.getColumnValue(0), this.getColumnIndex(0)); + this.$emit( + 'change', + this, + this.getColumnValue(0), + this.getColumnIndex(0) + ); } else { this.$emit('change', this, this.getValues(), columnIndex); } @@ -105,7 +110,10 @@ export default createComponent({ // set options of column by index setColumnValues(index, options) { const column = this.children[index]; - if (column && JSON.stringify(column.options) !== JSON.stringify(options)) { + if ( + column && + JSON.stringify(column.options) !== JSON.stringify(options) + ) { column.options = options; column.setIndex(0); } @@ -142,13 +150,70 @@ export default createComponent({ onCancel() { this.emit('cancel'); + }, + + genTitle() { + const titleSlot = this.slots('title'); + + if (titleSlot) { + return titleSlot; + } + + if (this.title) { + return
{this.title}
; + } + }, + + genToolbar() { + if (this.showToolbar) { + return ( +
+ {this.slots() || [ + , + this.genTitle(), + + ]} +
+ ); + } + }, + + genColumns() { + const columns = this.simple ? [this.columns] : this.columns; + + return columns.map((item, index) => ( + { + this.onChange(index); + }} + /> + )); } }, render(h) { const { itemHeight } = this; const wrapHeight = itemHeight * this.visibleItemCount; - const columns = this.simple ? [this.columns] : this.columns; const frameStyle = { height: `${itemHeight}px` @@ -162,49 +227,25 @@ export default createComponent({ backgroundSize: `100% ${(wrapHeight - itemHeight) / 2}px` }; - const Toolbar = this.showToolbar && ( -
- {this.slots() || [ - , - this.slots('title') || - (this.title && ( -
{this.title}
- )), - - ]} -
- ); - return (
- {this.toolbarPosition === 'top' ? Toolbar : h()} + {this.toolbarPosition === 'top' ? this.genToolbar() : h()} {this.loading ? : h()} {this.slots('columns-top')} -
- {columns.map((item, index) => ( - { - this.onChange(index); - }} - /> - ))} +
+ {this.genColumns()}
-
+
{this.slots('columns-bottom')} - {this.toolbarPosition === 'bottom' ? Toolbar : h()} + {this.toolbarPosition === 'bottom' ? this.genToolbar() : h()}
); } diff --git a/src/picker/test/__snapshots__/demo.spec.js.snap b/src/picker/test/__snapshots__/demo.spec.js.snap index 5d427bec3..1464ed379 100644 --- a/src/picker/test/__snapshots__/demo.spec.js.snap +++ b/src/picker/test/__snapshots__/demo.spec.js.snap @@ -42,8 +42,8 @@ exports[`renders demo correctly 1`] = `
-
-
标题
+
+
标题
diff --git a/src/picker/test/__snapshots__/index.spec.js.snap b/src/picker/test/__snapshots__/index.spec.js.snap index a1d427794..090e416a7 100644 --- a/src/picker/test/__snapshots__/index.spec.js.snap +++ b/src/picker/test/__snapshots__/index.spec.js.snap @@ -30,7 +30,7 @@ exports[`column watch default index 2`] = ` exports[`columns-top、columns-bottom prop 1`] = `
-
+
Custom Columns Top
@@ -57,7 +57,7 @@ exports[`not allow html 1`] = ` exports[`render title slot 1`] = `
-
Custom title
+
Custom title
@@ -75,6 +75,6 @@ exports[`toolbar-position prop 1`] = `
-
+
`; diff --git a/src/sidebar/README.md b/src/sidebar/README.md index 1fff91773..bd8d6da67 100644 --- a/src/sidebar/README.md +++ b/src/sidebar/README.md @@ -52,6 +52,31 @@ export default { ``` +### Change Event + +```html + + + + + +``` + +```js +export default { + data() { + return { + activeKey: 0 + }; + }, + methods: { + onChange(index) { + Notify({ type: 'primary', message: index }); + } + } +} +``` + ## API ### Sidebar Props diff --git a/src/sidebar/README.zh-CN.md b/src/sidebar/README.zh-CN.md index 60cad4f07..4babe7765 100644 --- a/src/sidebar/README.zh-CN.md +++ b/src/sidebar/README.zh-CN.md @@ -58,6 +58,34 @@ export default { ``` + +### Change 事件 + +设置`change`方法来监听切换导航项时的事件 + +```html + + + + + +``` + +```js +export default { + data() { + return { + activeKey: 0 + }; + }, + methods: { + onChange(index) { + Notify({ type: 'primary', message: index }); + } + } +} +``` + ## API ### Sidebar Props diff --git a/src/sidebar/demo/index.vue b/src/sidebar/demo/index.vue index e69e78ed6..6e7abfa02 100644 --- a/src/sidebar/demo/index.vue +++ b/src/sidebar/demo/index.vue @@ -27,6 +27,15 @@ + + +

{{ $t('eventChange') }}

+ + + + + +
@@ -37,11 +46,15 @@ export default { 'zh-CN': { title: '标签名', showInfo: '提示信息', - disabled: '禁用选项' + disabled: '禁用选项', + eventChange: '切换事件', + selectTip: '你切换到了' }, 'en-US': { showInfo: 'Show Info', - disabled: 'Disabled' + disabled: 'Disabled', + eventChange: 'Change Event', + selectTip: 'You select ' } }, @@ -49,8 +62,18 @@ export default { return { activeKey1: 0, activeKey2: 0, - activeKey3: 0 + activeKey3: 0, + activeKey4: 0 }; + }, + + methods: { + onChange(index) { + this.$notify({ + type: 'primary', + message: `${this.$t('selectTip')} ${this.$t('title')}${index + 1}` + }); + } } }; diff --git a/src/sidebar/test/__snapshots__/demo.spec.js.snap b/src/sidebar/test/__snapshots__/demo.spec.js.snap index e2a143cc2..25f914d4f 100644 --- a/src/sidebar/test/__snapshots__/demo.spec.js.snap +++ b/src/sidebar/test/__snapshots__/demo.spec.js.snap @@ -54,6 +54,24 @@ exports[`renders demo correctly 1`] = `
+
`; diff --git a/src/stepper/README.md b/src/stepper/README.md index c0ac195d7..b6467231f 100644 --- a/src/stepper/README.md +++ b/src/stepper/README.md @@ -107,7 +107,9 @@ export default { | name | Stepper name | *string \| number* | - | 2.0.3 | | integer | Whether to allow only integers | *boolean* | `false` | - | | disabled | Disable value change | *boolean* | `false` | - | -| disable-input | Disable input | *boolean* | `false` | - | +| disable-plus | Whether to disable plus button | *boolean* | `false` | 2.2.16 | +| disable-minus | Whether to disable minus button | *boolean* | `false` | 2.2.16 | +| disable-input | Whether to disable input | *boolean* | `false` | - | | async-change | Whether to enable async change | *boolean* | `false` | - | - | | input-width | Input width | *string \| number* | `32px` | - | | button-size | Button size | *string \| number* | `28px` | 2.0.5 | diff --git a/src/stepper/README.zh-CN.md b/src/stepper/README.zh-CN.md index fed358fa9..5f0aa4c94 100644 --- a/src/stepper/README.zh-CN.md +++ b/src/stepper/README.zh-CN.md @@ -129,6 +129,8 @@ export default { | name | 标识符,可以在`change`事件回调参数中获取 | *string \| number* | - | 2.2.11 | | integer | 是否只允许输入整数 | *boolean* | `false` | - | | disabled | 是否禁用步进器 | *boolean* | `false` | - | +| disable-plus | 是否禁用增加按钮 | *boolean* | `false` | 2.2.16 | +| disable-minus | 是否禁用减少按钮 | *boolean* | `false` | 2.2.16 | | disable-input | 是否禁用输入框 | *boolean* | `false` | - | | async-change | 是否开启异步变更,开启后需要手动控制输入值 | *boolean* | `false` | - | | input-width | 输入框宽度,默认单位为`px` | *string \| number* | `32px` | - | diff --git a/src/stepper/index.js b/src/stepper/index.js index 44a5a6655..21d2abc14 100644 --- a/src/stepper/index.js +++ b/src/stepper/index.js @@ -25,6 +25,8 @@ export default createComponent({ inputWidth: [Number, String], buttonSize: [Number, String], asyncChange: Boolean, + disablePlus: Boolean, + disableMinus: Boolean, disableInput: Boolean, decimalLength: Number, name: { @@ -72,11 +74,11 @@ export default createComponent({ computed: { minusDisabled() { - return this.disabled || this.currentValue <= this.min; + return this.disabled || this.disableMinus || this.currentValue <= this.min; }, plusDisabled() { - return this.disabled || this.currentValue >= this.max; + return this.disabled || this.disablePlus || this.currentValue >= this.max; }, inputStyle() { @@ -253,6 +255,7 @@ export default createComponent({
+
步长设置
-
+
限制输入范围
-
+
限制输入整数
-
+
禁用状态
-
+
固定小数位数
-
+
自定义大小
-
+
异步变更
-
+
diff --git a/src/stepper/test/__snapshots__/index.spec.js.snap b/src/stepper/test/__snapshots__/index.spec.js.snap index 906faebe1..c9e506e91 100644 --- a/src/stepper/test/__snapshots__/index.spec.js.snap +++ b/src/stepper/test/__snapshots__/index.spec.js.snap @@ -1,9 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`disable stepper input 1`] = `
`; +exports[`disable stepper input 1`] = `
`; -exports[`disabled stepper 1`] = `
`; +exports[`disabled stepper 1`] = `
`; -exports[`input-width prop 1`] = `
`; +exports[`input-width prop 1`] = `
`; -exports[`show-plus & show-minus props 1`] = `
`; +exports[`show-plus & show-minus props 1`] = `
`; diff --git a/src/stepper/test/index.spec.js b/src/stepper/test/index.spec.js index a5a2deff2..29748616e 100644 --- a/src/stepper/test/index.spec.js +++ b/src/stepper/test/index.spec.js @@ -19,6 +19,35 @@ test('disable stepper input', () => { expect(wrapper).toMatchSnapshot(); }); +test('disable button', async () => { + const wrapper = mount(Stepper, { + propsData: { + value: 5 + } + }); + + const plus = wrapper.find('.van-stepper__plus'); + const minus = wrapper.find('.van-stepper__minus'); + + minus.trigger('click'); + + expect(wrapper.emitted('overlimit')).toBeFalsy(); + expect(wrapper.emitted('minus')).toBeTruthy(); + expect(wrapper.emitted('change')[0]).toEqual([4, { name: '' }]); + + wrapper.setProps({ + disablePlus: true, + disableMinus: true + }); + + await later(); + + minus.trigger('click'); + expect(wrapper.emitted('overlimit')[0][0]).toBe('minus'); + plus.trigger('click'); + expect(wrapper.emitted('overlimit')[1][0]).toBe('plus'); +}); + test('click button', () => { const wrapper = mount(Stepper, { propsData: { diff --git a/src/style/var.less b/src/style/var.less index 1172ad8aa..fc6ba8556 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -231,20 +231,20 @@ // Coupon @coupon-margin: 0 @padding-md @padding-md; -@coupon-content-height: 100px; -@coupon-content-padding: @padding-lg 0 0 @padding-md; +@coupon-content-height: 84px; +@coupon-content-padding: 14px 0; @coupon-background-color: @white; @coupon-active-background-color: @active-color; @coupon-border-radius: @border-radius-md; @coupon-box-shadow: 0 0 4px rgba(0, 0, 0, 0.1); -@coupon-head-width: 85px; +@coupon-head-width: 96px; @coupon-amount-color: @red; -@coupon-amount-font-size: 24px; -@coupon-currency-font-size: 50%; -@coupon-name-font-size: @font-size-lg; +@coupon-amount-font-size: 30px; +@coupon-currency-font-size: 40%; +@coupon-name-font-size: @font-size-md; @coupon-disabled-text-color: @gray-6; @coupon-description-padding: @padding-xs @padding-md; -@coupon-description-background-color: @background-color-light; +@coupon-description-background-color: @white; @coupon-description-border-color: @border-color; // CouponCell @@ -252,7 +252,7 @@ // CouponList @coupon-list-background-color: @background-color; -@coupon-list-field-padding: @padding-xs @padding-md; +@coupon-list-field-padding: 5px 0 5px @padding-md; @coupon-list-exchange-button-height: 32px; @coupon-list-empty-image-size: 200px; @coupon-list-empty-tip-color: @gray-6; diff --git a/src/swipe/README.zh-CN.md b/src/swipe/README.zh-CN.md index 27721b226..6e06c816c 100644 --- a/src/swipe/README.zh-CN.md +++ b/src/swipe/README.zh-CN.md @@ -181,3 +181,11 @@ export default { |------|------|------| | default | 轮播内容 | - | | indicator | 自定义指示器 | - | + +## 常见问题 + +### 滑动轮播时为什么触发了 click 事件? + +这种情况通常是由于项目中引入了`fastclick`库导致的。`fastclick`的原理是通过 Touch 事件模拟出 click 事件,而 Swipe 内部默认会阻止 touchmove 事件冒泡,干扰了 fastclick 的判断,导致出现这个问题。 + +将 Swipe 组件的 stop-propagation 属性设置为 false 即可避免该问题。 diff --git a/src/tabbar/README.md b/src/tabbar/README.md index 51cc9faf0..681150a0e 100644 --- a/src/tabbar/README.md +++ b/src/tabbar/README.md @@ -112,6 +112,31 @@ export default { ``` + +### Change Event + +```html + + Tab1 + Tab2 + Tab3 + Tab4 + +``` + +```js +export default { + methods: { + onChange(index) { + Notify({ type: 'primary', message: index }); + } + } +} +``` + ### Route Mode ```html diff --git a/src/tabbar/README.zh-CN.md b/src/tabbar/README.zh-CN.md index e2552ef9d..6df4dd309 100644 --- a/src/tabbar/README.zh-CN.md +++ b/src/tabbar/README.zh-CN.md @@ -118,6 +118,30 @@ export default { ``` +### Change 事件 + +```html + + 标签1 + 标签2 + 标签3 + 标签4 + +``` + +```js +export default { + methods: { + onChange(index) { + Notify({ type: 'primary', message: index }); + } + } +} +``` + ### 路由模式 标签栏支持路由模式,用于搭配`vue-router`使用。路由模式下会匹配页面路径和标签的`to`属性,并自动选中对应的标签 diff --git a/src/tabbar/demo/index.vue b/src/tabbar/demo/index.vue index c30966a86..96a25d7ff 100644 --- a/src/tabbar/demo/index.vue +++ b/src/tabbar/demo/index.vue @@ -48,6 +48,15 @@ {{ $t('tab') }} + + + + {{ $t('tab') + 1 }} + {{ $t('tab') + 2 }} + {{ $t('tab') + 3 }} + {{ $t('tab') + 4 }} + + @@ -58,13 +67,17 @@ export default { badge: '提示信息', customIcon: '自定义图标', customColor: '自定义颜色', - matchByName: '通过名称匹配' + matchByName: '通过名称匹配', + switchEvent: '切换标签事件', + selectTip: '你切换到了' }, 'en-US': { badge: 'Show Badge', customIcon: 'Custom Icon', customColor: 'Custom Color', - matchByName: 'Match by name' + matchByName: 'Match by name', + switchEvent: 'Change Event', + selectTip: 'You select ' } }, @@ -74,12 +87,22 @@ export default { active2: 0, active3: 0, active4: 0, + active5: 0, activeName: 'home', icon: { active: 'https://img.yzcdn.cn/vant/user-active.png', inactive: 'https://img.yzcdn.cn/vant/user-inactive.png' } }; + }, + + methods: { + onChange(index) { + this.$notify({ + type: 'primary', + message: `${this.$t('selectTip')} ${this.$t('tab')}${index + 1}` + }); + } } }; diff --git a/src/tabbar/test/__snapshots__/demo.spec.js.snap b/src/tabbar/test/__snapshots__/demo.spec.js.snap index 08cf7c656..5412410e6 100644 --- a/src/tabbar/test/__snapshots__/demo.spec.js.snap +++ b/src/tabbar/test/__snapshots__/demo.spec.js.snap @@ -154,5 +154,37 @@ exports[`renders demo correctly 1`] = `
+
+
+
+
+ + +
+
标签1
+
+
+
+ + +
+
标签2
+
+
+
+ + +
+
标签3
+
+
+
+ + +
+
标签4
+
+
+
`; diff --git a/src/uploader/index.js b/src/uploader/index.js index f232eeb70..3dfb8b3ea 100644 --- a/src/uploader/index.js +++ b/src/uploader/index.js @@ -144,12 +144,13 @@ export default createComponent({ }, onAfterRead(files, oversize) { + this.resetInput(); + if (oversize) { this.$emit('oversize', files, this.getDetail()); return; } - this.resetInput(); this.$emit('input', [...this.fileList, ...toArray(files)]); if (this.afterRead) {