diff --git a/src/picker/README.md b/src/picker/README.md index 13cdabbf7..65bce44f5 100644 --- a/src/picker/README.md +++ b/src/picker/README.md @@ -269,12 +269,14 @@ Picker events will pass different parameters according to the columns are single ### Slots -| Name | Description | -| -------------- | ---------------------------- | -| default | Custom toolbar content | -| title | Custom title | -| columns-top | Custom content above columns | -| columns-bottom | Custom content below columns | +| Name | Description | +| ------------------ | ---------------------------- | +| default | Custom toolbar content | +| title | Custom title | +| confirm `v2.10.11` | Custom confirm button text | +| cancel `v2.10.11` | Custom cancel button text | +| columns-top | Custom content above columns | +| columns-bottom | Custom content below columns | ### Data Structure of Column diff --git a/src/picker/README.zh-CN.md b/src/picker/README.zh-CN.md index 5274f0f39..10265a6c9 100644 --- a/src/picker/README.zh-CN.md +++ b/src/picker/README.zh-CN.md @@ -292,12 +292,14 @@ export default { ### Slots -| 名称 | 说明 | -| -------------- | ------------------ | -| default | 自定义顶部栏内容 | -| title | 自定义标题内容 | -| columns-top | 自定义选项上方内容 | -| columns-bottom | 自定义选项下方内容 | +| 名称 | 说明 | +| ------------------ | ---------------------- | +| default | 自定义整个顶部栏的内容 | +| title | 自定义标题内容 | +| confirm `v2.10.11` | 自定义确认按钮内容 | +| cancel `v2.10.11` | 自定义取消按钮内容 | +| columns-top | 自定义选项上方内容 | +| columns-bottom | 自定义选项下方内容 | ### Column 数据结构 diff --git a/src/picker/index.js b/src/picker/index.js index 96cbf07ba..aa496cd12 100644 --- a/src/picker/index.js +++ b/src/picker/index.js @@ -270,22 +270,30 @@ export default createComponent({ } }, + genCancel() { + return ( + + ); + }, + + genConfirm() { + return ( + + ); + }, + genToolbar() { if (this.showToolbar) { return (
{this.slots() || [ - , + this.genCancel(), this.genTitle(), - , + this.genConfirm(), ]}
); diff --git a/src/picker/test/__snapshots__/index.spec.js.snap b/src/picker/test/__snapshots__/index.spec.js.snap index 24c30aa69..a24c9adc9 100644 --- a/src/picker/test/__snapshots__/index.spec.js.snap +++ b/src/picker/test/__snapshots__/index.spec.js.snap @@ -88,6 +88,21 @@ exports[`not allow html 1`] = ` `; +exports[`render confirm/cancel slot 1`] = ` +
+
+ +
+
+
    +
    +
    +
    +
    + +
    +`; + exports[`render title slot 1`] = `
    Custom title
    diff --git a/src/picker/test/index.spec.js b/src/picker/test/index.spec.js index fed201fc3..46606c748 100644 --- a/src/picker/test/index.spec.js +++ b/src/picker/test/index.spec.js @@ -138,13 +138,23 @@ test('column watch default index', async () => { test('render title slot', () => { const wrapper = mount({ template: ` - + - + + `, + }); + + expect(wrapper).toMatchSnapshot(); +}); + +test('render confirm/cancel slot', () => { + const wrapper = mount({ + template: ` + + + + `, - components: { - Picker, - }, }); expect(wrapper).toMatchSnapshot();