mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-26 03:26:35 +08:00
[build] 2.4.3
This commit is contained in:
parent
dff2430383
commit
1daaca1538
54
dist/common/helper.js
vendored
54
dist/common/helper.js
vendored
@ -5,6 +5,56 @@ function extractComponentId(event = {}) {
|
|||||||
return componentId;
|
return componentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
const LIFE_CYCLE = ['onLoad', 'onReady', 'onShow', 'onHide', 'onUnload', 'onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onPageScroll'];
|
||||||
extractComponentId
|
/*
|
||||||
|
1. 直接合并所有生命周期函数
|
||||||
|
Page(extend({}, {
|
||||||
|
onLoad() {},
|
||||||
|
...
|
||||||
|
}));
|
||||||
|
|
||||||
|
2. 只合并指定的生命周期
|
||||||
|
const extendOnload = extend(['onLoad']);
|
||||||
|
Page(extendOnload({}, {
|
||||||
|
onLoad() {},
|
||||||
|
...
|
||||||
|
}));
|
||||||
|
*/
|
||||||
|
const extend = (obj, ...rest) => {
|
||||||
|
if (Array.isArray(obj)) {
|
||||||
|
let lifeCycleList = obj.filter(item => LIFE_CYCLE.indexOf(item) >= 0);
|
||||||
|
return extendWithLife.bind(null, lifeCycleList);
|
||||||
|
}
|
||||||
|
return extendWithLife(LIFE_CYCLE, obj, ...rest);
|
||||||
|
};
|
||||||
|
|
||||||
|
const extendWithLife = (lifeCycleList, target, ...objList) => {
|
||||||
|
objList.forEach((source) => {
|
||||||
|
if (source) {
|
||||||
|
let keys = Object.keys(source);
|
||||||
|
keys.forEach((key) => {
|
||||||
|
let value = source[key];
|
||||||
|
if (lifeCycleList.indexOf(key) >= 0 && typeof value === 'function') {
|
||||||
|
// 合并生命周期函数,可选择改成闭包函数列表
|
||||||
|
let funcArrayName = `__$${key}`;
|
||||||
|
if (!target[funcArrayName]) {
|
||||||
|
target[funcArrayName] = [value];
|
||||||
|
target[key] = function(...rest) {
|
||||||
|
target[funcArrayName].forEach(func => func.apply(this, rest));
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
target[funcArrayName].push(value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
target[key] = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return target;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
extractComponentId,
|
||||||
|
extend
|
||||||
};
|
};
|
||||||
|
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -7,3 +7,6 @@ exports.Switch = require('./switch/index');
|
|||||||
exports.Tab = require('./tab/index');
|
exports.Tab = require('./tab/index');
|
||||||
exports.Toast = require('./toast/index');
|
exports.Toast = require('./toast/index');
|
||||||
exports.TopTips = require('./toptips/index');
|
exports.TopTips = require('./toptips/index');
|
||||||
|
|
||||||
|
const { extend } = require('./common/helper');
|
||||||
|
exports.extend = extend;
|
||||||
|
2
dist/index.wxss
vendored
2
dist/index.wxss
vendored
File diff suppressed because one or more lines are too long
2
dist/panel/index.wxss
vendored
2
dist/panel/index.wxss
vendored
@ -1 +1 @@
|
|||||||
.zan-panel{position:relative;background:#fff;margin-top:10px;overflow:hidden}.zan-panel::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e5e5e5;border-top-width:1px;border-bottom-width:1px}.zan-panel-title{font-size:14px;line-height:1;color:#999;padding:20px 15px 0 15px}.zan-panel--without-margin-top{margin-top:0}
|
.zan-panel{position:relative;background:#fff;margin-top:10px;overflow:hidden}.zan-panel::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e5e5e5;border-top-width:1px;border-bottom-width:1px}.zan-panel-title{font-size:14px;line-height:1;color:#999;padding:20px 15px 0 15px}.zan-panel--without-margin-top{margin-top:0}.zan-panel--without-border::after{border:0 none}
|
Loading…
x
Reference in New Issue
Block a user