vue2-components-plus 1.0.38 → 1.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -74,7 +74,7 @@ const instance = window.NsDialog(
|
|
|
74
74
|
| `footerOption` | `Object` | `{}` | 透传给 `footerDom` 的 props |
|
|
75
75
|
| `footerTitle` | `Object` | `{ close: '取消', confirm: '确定' }` | 默认底部按钮文案 |
|
|
76
76
|
| `footerEvents` | `Object` | `{}` | 透传给 `footerDom` 的事件 |
|
|
77
|
-
| `footerButtonReverse` | `Boolean` | `false` |
|
|
77
|
+
| `footerButtonReverse` | `Boolean` | `false` | 仅对默认底部按钮顺序生效:`true`=确认在左、取消在右;`false`=取消在左、确认在右。当前工厂创建时会强制为 `true` |
|
|
78
78
|
| `footerCloseOnly` | `Boolean` | `false` | 仅对默认底部生效;设为 `true` 时只显示关闭按钮,不显示确认按钮 |
|
|
79
79
|
| `immediately` | `Boolean` | `false` | 点击确认后是否先关闭再执行 `confirm` |
|
|
80
80
|
| `close` | `Function` | `null` | `el-dialog` 的 `close` 阶段回调 |
|
|
@@ -87,6 +87,24 @@ const instance = window.NsDialog(
|
|
|
87
87
|
| `store` | `Object` | `null` | 注入给动态实例的 Vuex store |
|
|
88
88
|
| `pinia` | `Object` | `null` | 注入给动态实例的 Pinia 实例 |
|
|
89
89
|
|
|
90
|
+
### 4.1 易混淆字段详解(中文)
|
|
91
|
+
|
|
92
|
+
| 字段 | 详细说明 | 常见误区 |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| `option` | 透传给内容组件的 props,等价于 `<component v-bind="option" />` | 不是 NsDialog 自己的 props,不会直接改弹窗壳子 |
|
|
95
|
+
| `events` | 透传给内容组件的事件对象,等价于 `<component v-on="events" />`,且内部会自动合并一个 `close` 事件 | 以为必须自己传 `close`;实际上组件已注入 |
|
|
96
|
+
| `showFooter` | 控制底部区域是否整体显示 | 设为 `false` 后,默认按钮和自定义 footer 都不会出现 |
|
|
97
|
+
| `footerDom` | 自定义底部组件;一旦提供,默认取消/确定按钮不再渲染 | 以为还能同时显示默认按钮;实际二选一 |
|
|
98
|
+
| `footerTitle` | 仅影响默认底部按钮文案,不影响自定义 `footerDom` | 给了 `footerDom` 后再改 `footerTitle` 不会生效 |
|
|
99
|
+
| `footerEvents` | 仅透传给 `footerDom` 的事件,默认按钮不会读取这里的 `confirm` | 以为能通过 `footerEvents.confirm` 控制默认确认按钮 |
|
|
100
|
+
| `footerButtonReverse` | 仅控制默认按钮顺序:`true`=确定在左,`false`=确定在右 | 以为会影响自定义 `footerDom`;不会 |
|
|
101
|
+
| `footerCloseOnly` | 仅默认底部生效;`true` 时只渲染取消按钮 | 以为会隐藏自定义 footer;不会 |
|
|
102
|
+
| `immediately` | 默认确认按钮点击后是否先关窗再执行 `confirm` | 设为 `true` 时 `confirm` 拿不到 `loadingProxy` |
|
|
103
|
+
| `confirm` | 默认确认按钮回调;建议手动控制 `closeFn` 与 loading 状态 | 以为 return Promise 就会自动关窗;当前实现不会自动等待 |
|
|
104
|
+
| `close` / `closed` | 分别对应 `el-dialog` 的 `close` 和 `closed` 生命周期 | 误把资源释放写在 `close`;更稳妥放在 `closed` |
|
|
105
|
+
| `x` / `y` | 传任一项就切换为 fixed 定位,支持数字和带单位字符串 | 只传 `x` 不传 `y` 时,`y` 会按居中 top 自动计算 |
|
|
106
|
+
| `maxSize` | 传函数才显示最大化按钮,函数返回 `{ width, height, x, y }` | 以为是布尔开关;实际必须是函数 |
|
|
107
|
+
|
|
90
108
|
## 5. 核心行为
|
|
91
109
|
|
|
92
110
|
### 5.1 内容组件如何接收数据
|
|
@@ -105,13 +123,25 @@ const instance = window.NsDialog(
|
|
|
105
123
|
### 5.3 默认确认按钮行为
|
|
106
124
|
|
|
107
125
|
- 只有在 `showFooter=true` 且未传 `footerDom` 时,才会显示默认确认/取消按钮
|
|
126
|
+
- `footerButtonReverse=true` 时顺序是「确定 | 取消」,`footerButtonReverse=false` 时顺序是「取消 | 确定」
|
|
127
|
+
- 通过 `window.NsDialog(...)` 工厂创建时,当前实现会把 `footerButtonReverse` 强制设为 `true`
|
|
108
128
|
- 若 `footerCloseOnly=true`,默认底部只显示关闭按钮
|
|
109
129
|
- 点击默认确认按钮后会执行 `dealConfirm`
|
|
110
130
|
- 若未配置 `confirm`,按钮只会短暂进入 loading 后立即结束,不会自动关闭
|
|
111
131
|
- 若配置了 `confirm` 且不调用 `closeFn()`,需要在业务侧手动 `loadingProxy.value = false` 结束 loading
|
|
112
132
|
- 若 `confirm` 中调用了 `closeFn()`,组件会关闭,并自动弹出一次 `操作成功`
|
|
113
133
|
|
|
114
|
-
### 5.4
|
|
134
|
+
### 5.4 底部按钮显示矩阵(默认底部)
|
|
135
|
+
|
|
136
|
+
仅在 `showFooter=true` 且 `footerDom` 未传时适用:
|
|
137
|
+
|
|
138
|
+
| 条件 | 显示结果 |
|
|
139
|
+
|---|---|
|
|
140
|
+
| `footerCloseOnly=true` | 仅显示「取消」按钮 |
|
|
141
|
+
| `footerCloseOnly=false` 且 `footerButtonReverse=true` | 显示「确定 | 取消」 |
|
|
142
|
+
| `footerCloseOnly=false` 且 `footerButtonReverse=false` | 显示「取消 | 确定」 |
|
|
143
|
+
|
|
144
|
+
### 5.5 `immediately=true` 的真实行为
|
|
115
145
|
|
|
116
146
|
这一点是 AI 生成代码最容易写错的地方。
|
|
117
147
|
|
|
@@ -120,14 +150,14 @@ const instance = window.NsDialog(
|
|
|
120
150
|
- 当前实现不会传入第三个 `loadingProxy`
|
|
121
151
|
- 因为弹窗已经先关闭,所以 `immediately=true` 更适合“无需等待结果、触发即关”的场景
|
|
122
152
|
|
|
123
|
-
### 5.
|
|
153
|
+
### 5.6 拖拽、定位、最大化
|
|
124
154
|
|
|
125
155
|
- `draggable=true` 时,只有标题栏可拖拽
|
|
126
156
|
- 只要传了 `x` 或 `y`,弹窗就改为 `position: fixed`
|
|
127
157
|
- 最大化按钮是否显示,不取决于单独开关,而是取决于 `maxSize` 是否为函数
|
|
128
158
|
- `maxSize()` 返回的对象支持 `width`、`height`、`x`、`y`
|
|
129
159
|
|
|
130
|
-
### 5.
|
|
160
|
+
### 5.7 回车行为
|
|
131
161
|
|
|
132
162
|
- 当 `visible=true`、`showFooter=true`、`footerDom` 不存在时,按回车会触发默认确认逻辑
|
|
133
163
|
- 当 `footerCloseOnly=true` 时,即使使用默认底部,回车也不会触发确认
|