12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- /*
- * @Author: Rindy
- * @Date: 2021-09-14 20:02:23
- * @LastEditors: Rindy
- * @LastEditTime: 2021-09-14 20:03:48
- * @Description:
- */
- /**
- * 对象属性拷贝
- *
- * @param {Object} target 目标对象
- * @param {Object} source 源对象
- * @return {Object} 返回目标对象
- */
- export function extend(target, source) {
- for (var key in source) {
- if (source.hasOwnProperty(key)) {
- var value = source[key]
- if (typeof value !== 'undefined') {
- target[key] = value
- }
- }
- }
- return target
- }
- /**
- * 构建类之间的继承关系
- *
- * @param {Function} subClass 子类函数
- * @param {Function} superClass 父类函数
- */
- export function inherits(subClass, superClass) {
- /* jshint -W054 */
- var subClassProto = subClass.prototype
- var F = new Function()
- F.prototype = superClass.prototype
- subClass.prototype = new F()
- subClass.prototype.constructor = subClass
- extend(subClass.prototype, subClassProto)
- /* jshint +W054 */
- }
|