Skip to content

Commit

Permalink
feat(picker): “确定”和“取消”按钮文字自定义 #439
Browse files Browse the repository at this point in the history
  • Loading branch information
richard1015 committed Jun 3, 2021
1 parent c88da36 commit 591e76d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
6 changes: 4 additions & 2 deletions src/packages/__VUE/picker/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
title="城市选择"
@confirm="confirm"
@close="close"
></nut-picker>
>
</nut-picker>
<nut-picker
v-model:visible="show2"
:list-data="listData2"
title="多列选择"
@confirm="confirm2"
@close="close"
></nut-picker>
>
</nut-picker>
<nut-picker
v-model:visible="show3"
:list-data="listData3"
Expand Down
30 changes: 16 additions & 14 deletions src/packages/__VUE/picker/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,23 @@ export default createDemo({

### Props

| 参数 | 说明 | 类型 | 默认值 |
|--------------|----------------------------------|--------|------------------|
| v-model:visible | 是否可见 | Boolean | false |
| title | 设置标题 | String | - |
| list-data | 列表数据 | Array | - |
| default-value-index | 初始选中项的索引,默认为 0 | number | 0 |
| teleport | 指定挂载节点 | String | "body" |
| close-on-click-overlay | 点击蒙层是否关闭对话框 | Boolean | false |
| lock-scroll | 背景是否锁定 | Boolean | false |
| 参数 | 说明 | 类型 | 默认值 |
|------------------------|----------------------------|---------|--------|
| v-model:visible | 是否可见 | Boolean | false |
| title | 设置标题 | String | - |
| cancel-text | 取消按钮文案 | String | 取消 |
| ok-text | 确定按钮文案 | String | 确定 |
| list-data | 列表数据 | Array | - |
| default-value-index | 初始选中项的索引,默认为 0 | number | 0 |
| teleport | 指定挂载节点 | String | "body" |
| close-on-click-overlay | 点击蒙层是否关闭对话框 | Boolean | false |
| lock-scroll | 背景是否锁定 | Boolean | false |

### Events

| 事件名 | 说明 | 回调参数 |
|--------|----------------|--------------|
| close | 关闭弹窗时触发 | event: Event |
| confirm | 点击确认时候触发 | event: Event |
| change | 改变时触发 | val |
| 事件名 | 说明 | 回调参数 |
|---------|------------------|--------------|
| close | 关闭弹窗时触发 | event: Event |
| confirm | 点击确认时候触发 | event: Event |
| change | 改变时触发 | val |

16 changes: 12 additions & 4 deletions src/packages/__VUE/picker/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
@close="close"
>
<view class="nut-picker__bar">
<view class="nut-picker__left nut-picker__button" @click="close"
>取消</view
>
<view class="nut-picker__left nut-picker__button" @click="close">{{
cancelText
}}</view>
<view> {{ title }}</view>
<view class="nut-picker__button" @click="confirm()">确定</view>
<view class="nut-picker__button" @click="confirm()">{{ okText }}</view>
</view>

<view class="nut-picker__column">
Expand Down Expand Up @@ -71,6 +71,14 @@ export default create({
type: String,
default: ''
},
cancelText: {
type: String,
default: '取消'
},
okText: {
type: String,
default: '确定'
},
...commonProps
},
emits: ['close', 'change', 'confirm', 'update:visible'],
Expand Down

0 comments on commit 591e76d

Please sign in to comment.