From cf3b797b2091f4531d1a08df0abe70105717702b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Mon, 3 Jun 2019 11:06:27 +0800 Subject: [PATCH] [bugfix] Area: should support set columns-num dynamically --- packages/area/index.js | 6 +++++ .../test/__snapshots__/index.spec.js.snap | 26 +++++++++++++++++++ packages/area/test/index.spec.js | 16 ++++++++++++ 3 files changed, 48 insertions(+) diff --git a/packages/area/index.js b/packages/area/index.js index 7d17b8e61..e10fdee84 100644 --- a/packages/area/index.js +++ b/packages/area/index.js @@ -54,6 +54,12 @@ export default sfc({ handler() { this.setValues(); } + }, + + columnsNum() { + this.$nextTick(() => { + this.setValues(); + }); } }, diff --git a/packages/area/test/__snapshots__/index.spec.js.snap b/packages/area/test/__snapshots__/index.spec.js.snap index 5021bcc1f..b8f9bef35 100644 --- a/packages/area/test/__snapshots__/index.spec.js.snap +++ b/packages/area/test/__snapshots__/index.spec.js.snap @@ -96,6 +96,32 @@ exports[`change option 3`] = ` `; +exports[`columns-num prop 1`] = ` +
+
+
取消
+
确认
+
+ +
+
+
    +
  • 北京市
  • +
  • 天津市
  • +
+
+
+
    +
  • 北京市
  • +
  • +
+
+
+
+
+
+`; + exports[`reset method 1`] = `
diff --git a/packages/area/test/index.spec.js b/packages/area/test/index.spec.js index 229fddbeb..7df588f3a 100644 --- a/packages/area/test/index.spec.js +++ b/packages/area/test/index.spec.js @@ -106,3 +106,19 @@ test('reset method', async () => { wrapper.vm.reset(); expect(wrapper).toMatchSnapshot(); }); + +test('columns-num prop', async () => { + const wrapper = mount(Area, { + propsData: { + areaList, + columnsNum: 3 + } + }); + + wrapper.setProps({ + columnsNum: 2 + }); + + await later(); + expect(wrapper).toMatchSnapshot(); +});