1
0
mirror of https://gitee.com/vant-contrib/vant.git synced 2025-04-06 03:57:59 +08:00

fix picker

This commit is contained in:
cookfront 2017-03-13 19:40:25 +08:00
parent 2db76f207f
commit 3696fadc25
3 changed files with 11 additions and 9 deletions
docs/examples-docs
packages/picker/src

@ -27,7 +27,6 @@
<span class="zan-card__price">¥ 2.00</span> <span class="zan-card__price">¥ 2.00</span>
</div> </div>
<div class="zan-card__row" slot="desc"> <div class="zan-card__row" slot="desc">
<h4 class="zan-card__desc">商品sku</h4>
<span class="zan-card__num">x 2</span> <span class="zan-card__num">x 2</span>
</div> </div>
<div class="zan-card__footer" slot="footer"> <div class="zan-card__footer" slot="footer">

@ -6,7 +6,7 @@
class="zan-picker-column__item" class="zan-picker-column__item"
:class="{ 'zan-picker-column__item--selected': item === currentValue }" :class="{ 'zan-picker-column__item--selected': item === currentValue }"
:style="{ height: itemHeight + 'px', lineHeight: itemHeight + 'px' }"> :style="{ height: itemHeight + 'px', lineHeight: itemHeight + 'px' }">
{{item}} {{ typeof item === 'object' && item[valueKey] ? item[valueKey] : item }}
</div> </div>
</div> </div>
</div> </div>
@ -52,7 +52,8 @@ export default {
type: Number, type: Number,
default: DEFAULT_ITEM_HEIGHT default: DEFAULT_ITEM_HEIGHT
}, },
value: {} value: {},
valueKey: String
}, },
data() { data() {

@ -14,7 +14,8 @@
:class-name="item.className" :class-name="item.className"
:itemHeight="itemHeight" :itemHeight="itemHeight"
:visible-item-count="visibleItemCount" :visible-item-count="visibleItemCount"
@change="columnValueChange"> :value-key="valueKey"
@change="columnValueChange(index)">
</picker-column> </picker-column>
<div class="zan-picker-center-highlight" :style="{ height: itemHeight + 'px', marginTop: -itemHeight / 2 + 'px' }"></div> <div class="zan-picker-center-highlight" :style="{ height: itemHeight + 'px', marginTop: -itemHeight / 2 + 'px' }"></div>
</div> </div>
@ -63,7 +64,8 @@ export default {
showToolbar: { showToolbar: {
type: Boolean, type: Boolean,
default: false default: false
} },
valueKey: String
}, },
computed: { computed: {
@ -81,16 +83,16 @@ export default {
methods: { methods: {
handlePickerCancel() { handlePickerCancel() {
this.$emit('cancel'); this.$emit('cancel', this.values);
}, },
handlePickerConfirm() { handlePickerConfirm() {
this.$emit('confirm'); this.$emit('confirm', this.values);
}, },
/** /**
* 处理列`change`事件 * 处理列`change`事件
*/ */
columnValueChange() { columnValueChange(index) {
this.$emit('change', this, this.values); this.$emit('change', this, this.values, index);
}, },
/** /**