[Improvement] Actionsheet: add select event (#1594)

This commit is contained in:
neverland
2018-08-06 11:46:10 +08:00
committed by GitHub
parent 58eab6f2df
commit 1f67c28998
6 changed files with 64 additions and 36 deletions

View File

@@ -2,12 +2,18 @@
<demo-section>
<demo-block :title="$t('basicUsage')">
<van-button @click="show1 = true">{{ $t('button1') }}</van-button>
<van-actionsheet v-model="show1" :actions="actions" />
<van-actionsheet v-model="show1" :actions="actions" @select="onSelect" />
</demo-block>
<demo-block :title="$t('title2')">
<van-button @click="show2 = true">{{ $t('button2') }}</van-button>
<van-actionsheet v-model="show2" :actions="actions" :cancel-text="$t('cancel')" @cancel="handleCancel" />
<van-actionsheet
v-model="show2"
:actions="actions"
:cancel-text="$t('cancel')"
@cancel="onCancel"
@select="onSelect"
/>
</demo-block>
<demo-block :title="$t('title3')">
@@ -53,20 +59,22 @@ export default {
computed: {
actions() {
return [
{ name: this.$t('option'), callback: this.onClick },
{ name: this.$t('option') },
{ name: this.$t('option'), subname: this.$t('description') },
{ name: this.$t('option'), loading: true },
{ loading: true },
{ name: this.$t('disabledOption'), disabled: true }
];
}
},
methods: {
onClick(item) {
onSelect(item) {
this.show1 = false;
this.show2 = false;
this.$toast(item.name);
},
handleCancel() {
onCancel() {
this.$toast('cancel');
}
}
@@ -75,10 +83,6 @@ export default {
<style lang="postcss">
.demo-actionsheet {
.actionsheet-wx {
color: #06bf04;
}
.van-button {
margin-left: 15px;
}