Skip to content

Commit

Permalink
feat: action-sheet组件支持v-model:show双向绑定
Browse files Browse the repository at this point in the history
  • Loading branch information
jry committed Aug 1, 2024
1 parent 195a243 commit 522c15c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
19 changes: 16 additions & 3 deletions src/pages/componentsA/button/button.nvue
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,26 @@
></up-button>
</view>
</view>
</view>
</view>
<up-action-sheet
v-model:show="show"
:actions="[{
name: '选项1',
},
{
name: '选项2',
}]"
:closeOnClickOverlay="false"
>
</up-action-sheet>
</view>
</template>

<script>
export default {
data() {
return {
return {
show: false,
// type: 'default',
// disabled: false
}
Expand All @@ -308,7 +320,8 @@
}, 2000)
},
methods: {
click() {
click() {
this.show = true;
console.log('click');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,23 +166,26 @@
}
},
},
emits: ["close", "select"],
emits: ["close", "select", "update:show"],
methods: {
closeHandler() {
// 允许点击遮罩关闭时,才发出close事件
if(this.closeOnClickOverlay) {
this.$emit('update:show')
this.$emit('close')
}
},
// 点击取消按钮
cancel() {
this.$emit('update:show')
this.$emit('close')
},
selectHandler(index) {
const item = this.actions[index]
if (item && !item.disabled && !item.loading) {
this.$emit('select', item)
if (this.closeOnClickAction) {
this.$emit('update:show')
this.$emit('close')
}
}
Expand Down

0 comments on commit 522c15c

Please sign in to comment.