Skip to content

Commit

Permalink
fix(core): mixin 数组被转换成了对象 (eleme#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
hwaphon committed Oct 30, 2023
1 parent 0b63312 commit c895e30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,10 @@ function processMixinsOrBehaviors<
// 合并 数据
// 如 props/properties/data/methods
if (typeof current[name] === 'object') {
result[name] = { ...result[name], ...current[name] }
// 对象类型还可能包含数组,对数组做单独处理
if (Array.isArray(curr[name])) {
result[name] = [...(result[name] || []), ...curr[name]]
} else result[name] = { ...result[name], ...current[name] }
}
// 合并 方法
else if (typeof current[name] === 'function') {
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,10 @@ function processMixins(
Object.keys(curr).forEach((name) => {
// 合并 数据
if (typeof curr[name] === 'object') {
result[name] = { ...result[name], ...curr[name] }
// 对象类型还可能包含数组,对数组做单独处理
if (Array.isArray(curr[name])) {
result[name] = [...(result[name] || []), ...curr[name]]
} else result[name] = { ...result[name], ...curr[name] }
}
// 合并 方法
else if (typeof curr[name] === 'function') {
Expand Down

0 comments on commit c895e30

Please sign in to comment.