Commit ae7821e29690bea8934ea724bfd0ae4e2cf30c77

Authored by Vben
1 parent a1d956d3

fix(modal): ensure that props are passed correctly,fix #897

CHANGELOG.zh_CN.md
... ... @@ -26,6 +26,7 @@
26 26 - 修复菜单默认折叠的配置不起作用的问题
27 27 - 修复`safari`浏览器报错导致网站打不开
28 28 - 修复在 window 上,拉取代码后 eslint 因 endOfLine 而保错问题
  29 +- **Modal** 确保 props 正确被传递
29 30  
30 31 ### 🎫 Chores
31 32  
... ...
src/components/Modal/src/BasicModal.vue
... ... @@ -18,7 +18,7 @@
18 18 </template>
19 19  
20 20 <template #footer v-if="!$slots.footer">
21   - <ModalFooter v-bind="getProps" @ok="handleOk" @cancel="handleCancel">
  21 + <ModalFooter v-bind="getBindValue" @ok="handleOk" @cancel="handleCancel">
22 22 <template #[item]="data" v-for="item in Object.keys($slots)">
23 23 <slot :name="item" v-bind="data"></slot>
24 24 </template>
... ... @@ -82,7 +82,7 @@
82 82 setup(props, { emit, attrs }) {
83 83 const visibleRef = ref(false);
84 84 const propsRef = ref<Partial<ModalProps> | null>(null);
85   - const modalWrapperRef = ref<ComponentRef>(null);
  85 + const modalWrapperRef = ref<any>(null);
86 86  
87 87 // modal Bottom and top height
88 88 const extHeightRef = ref(0);
... ... @@ -133,7 +133,7 @@
133 133 });
134 134  
135 135 const getBindValue = computed((): Recordable => {
136   - const attr = { ...attrs, ...unref(getProps) };
  136 + const attr = { ...attrs, ...unref(getMergeProps), visible: unref(visibleRef) };
137 137 if (unref(fullScreenRef)) {
138 138 return omit(attr, 'height');
139 139 }
... ...
src/views/demo/comp/modal/Modal1.vue
... ... @@ -8,7 +8,7 @@
8 8 @visible-change="handleShow"
9 9 >
10 10 <template #insertFooter>
11   - <a-button type="danger" @click="setLines" :disabled="loading">点我更新内容</a-button>
  11 + <a-button type="primary" danger @click="setLines" :disabled="loading">点我更新内容</a-button>
12 12 </template>
13 13 <template v-if="loading">
14 14 <div class="empty-tips"> 加载中,稍等3秒…… </div>
... ...
src/views/demo/comp/modal/Modal2.vue
1 1 <template>
2 2 <BasicModal
3   - v-bind="$attrs"
4 3 @register="register"
5 4 title="Modal Title"
6 5 :helpMessage="['提示1', '提示2']"
  6 + :okButtonProps="{ disabled: true }"
7 7 >
8 8 <a-button type="primary" @click="closeModal" class="mr-2"> 从内部关闭弹窗 </a-button>
9   -
10 9 <a-button type="primary" @click="setModalProps"> 从内部修改title </a-button>
11 10 </BasicModal>
12 11 </template>
... ...
src/views/demo/system/account/AccountDetail.vue
... ... @@ -6,7 +6,7 @@
6 6 @back="goBack"
7 7 >
8 8 <template #extra>
9   - <a-button type="danger"> 禁用账号 </a-button>
  9 + <a-button type="primary" danger> 禁用账号 </a-button>
10 10 <a-button type="primary"> 修改密码 </a-button>
11 11 </template>
12 12 <template #footer>
... ...