wecui
Version:
一款基于Vue2.x版本的移动端web组件
18 lines (17 loc) • 624 B
JavaScript
var isNil = require('./isNil');
var assert = require('./assert');
// safe mixin, cannot override props unless specified
module.exports = function mixin(target, source, overwrite) {
if (isNil(source)) { return target; }
for (var k in source) {
if (source.hasOwnProperty(k)) {
if (overwrite !== true) {
if (process.env.NODE_ENV !== 'production') {
assert(!target.hasOwnProperty(k), function () { return 'Invalid call to mixin(target, source, [overwrite]): cannot overwrite property "' + k + '" of target object'; });
}
}
target[k] = source[k];
}
}
return target;
};