@tarojs/with-weapp 3.5.10 → 3.6.0-alpha.0
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.
- package/dist/index.esm.js +37 -212
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +37 -212
- package/dist/index.js.map +1 -1
- package/dist/with-weapp.js +37 -212
- package/dist/with-weapp.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -34,25 +34,19 @@ var json = JSON;
|
|
|
34
34
|
var clone = function clone(obj) {
|
|
35
35
|
return json.parse(stringify(obj));
|
|
36
36
|
};
|
|
37
|
-
|
|
38
37
|
var isArray = Array.isArray || function (x) {
|
|
39
38
|
return {}.toString.call(x) === '[object Array]';
|
|
40
39
|
};
|
|
41
|
-
|
|
42
40
|
var objectKeys = Object.keys || function (obj) {
|
|
43
41
|
var has = Object.prototype.hasOwnProperty || function () {
|
|
44
42
|
return true;
|
|
45
43
|
};
|
|
46
|
-
|
|
47
44
|
var keys = [];
|
|
48
|
-
|
|
49
45
|
for (var key in obj) {
|
|
50
46
|
if (has.call(obj, key)) keys.push(key);
|
|
51
47
|
}
|
|
52
|
-
|
|
53
48
|
return keys;
|
|
54
49
|
};
|
|
55
|
-
|
|
56
50
|
function stringify(obj, opts) {
|
|
57
51
|
if (!opts) opts = {};
|
|
58
52
|
if (typeof opts === 'function') opts = {
|
|
@@ -61,11 +55,9 @@ function stringify(obj, opts) {
|
|
|
61
55
|
var space = opts.space || '';
|
|
62
56
|
if (typeof space === 'number') space = Array(space + 1).join(' ');
|
|
63
57
|
var cycles = typeof opts.cycles === 'boolean' ? opts.cycles : false;
|
|
64
|
-
|
|
65
58
|
var replacer = opts.replacer || function (key, value) {
|
|
66
59
|
return value;
|
|
67
60
|
};
|
|
68
|
-
|
|
69
61
|
var cmp = opts.cmp && function (f) {
|
|
70
62
|
return function (node) {
|
|
71
63
|
return function (a, b) {
|
|
@@ -81,53 +73,41 @@ function stringify(obj, opts) {
|
|
|
81
73
|
};
|
|
82
74
|
};
|
|
83
75
|
}(opts.cmp);
|
|
84
|
-
|
|
85
76
|
var seen = [];
|
|
86
77
|
return function stringify(parent, key, node, level) {
|
|
87
78
|
var indent = space ? '\n' + new Array(level + 1).join(space) : '';
|
|
88
79
|
var colonSeparator = space ? ': ' : ':';
|
|
89
|
-
|
|
90
80
|
if (node && node.toJSON && typeof node.toJSON === 'function') {
|
|
91
81
|
node = node.toJSON();
|
|
92
82
|
}
|
|
93
|
-
|
|
94
83
|
node = replacer.call(parent, key, node);
|
|
95
|
-
|
|
96
84
|
if (node === undefined) {
|
|
97
85
|
return;
|
|
98
86
|
}
|
|
99
|
-
|
|
100
87
|
if (_typeof__default["default"](node) !== 'object' || node === null) {
|
|
101
88
|
return json.stringify(node);
|
|
102
89
|
}
|
|
103
|
-
|
|
104
90
|
if (isArray(node)) {
|
|
105
91
|
var out = [];
|
|
106
|
-
|
|
107
92
|
for (var i = 0; i < node.length; i++) {
|
|
108
93
|
var item = stringify(node, i, node[i], level + 1) || json.stringify(null);
|
|
109
94
|
out.push(indent + space + item);
|
|
110
95
|
}
|
|
111
|
-
|
|
112
96
|
return '[' + out.join(',') + indent + ']';
|
|
113
97
|
} else {
|
|
114
98
|
if (seen.indexOf(node) !== -1) {
|
|
115
99
|
if (cycles) return json.stringify('__cycle__');
|
|
116
100
|
throw new TypeError('Converting circular structure to JSON');
|
|
117
101
|
} else seen.push(node);
|
|
118
|
-
|
|
119
102
|
var keys = objectKeys(node).sort(cmp && cmp(node));
|
|
120
103
|
var _out = [];
|
|
121
|
-
|
|
122
104
|
for (var _i = 0; _i < keys.length; _i++) {
|
|
123
105
|
var _key = keys[_i];
|
|
124
106
|
var value = stringify(node, _key, node[_key], level + 1);
|
|
125
107
|
if (!value) continue;
|
|
126
108
|
var keyValue = json.stringify(_key) + colonSeparator + value;
|
|
127
|
-
|
|
128
109
|
_out.push(indent + space + keyValue);
|
|
129
110
|
}
|
|
130
|
-
|
|
131
111
|
seen.splice(seen.indexOf(node), 1);
|
|
132
112
|
return '{' + _out.join(',') + indent + '}';
|
|
133
113
|
}
|
|
@@ -143,29 +123,24 @@ var FUNCTIONTYPE = '[object Function]';
|
|
|
143
123
|
function diff(current, pre) {
|
|
144
124
|
var result = {};
|
|
145
125
|
syncKeys(current, pre);
|
|
146
|
-
|
|
147
126
|
_diff(current, pre, '', result);
|
|
148
|
-
|
|
149
127
|
return result;
|
|
150
128
|
}
|
|
151
|
-
|
|
152
129
|
function syncKeys(current, pre) {
|
|
153
130
|
if (current === pre) return;
|
|
154
131
|
var rootCurrentType = type(current);
|
|
155
132
|
var rootPreType = type(pre);
|
|
156
|
-
|
|
157
133
|
if (rootCurrentType == OBJECTTYPE && rootPreType == OBJECTTYPE) {
|
|
158
134
|
// if(Object.keys(current).length >= Object.keys(pre).length){
|
|
159
135
|
for (var key in pre) {
|
|
160
136
|
var currentValue = current[key];
|
|
161
|
-
|
|
162
137
|
if (currentValue === undefined) {
|
|
163
138
|
current[key] = null;
|
|
164
139
|
} else {
|
|
165
140
|
syncKeys(currentValue, pre[key]);
|
|
166
141
|
}
|
|
167
|
-
}
|
|
168
|
-
|
|
142
|
+
}
|
|
143
|
+
// }
|
|
169
144
|
} else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) {
|
|
170
145
|
if (current.length >= pre.length) {
|
|
171
146
|
pre.forEach(function (item, index) {
|
|
@@ -174,12 +149,10 @@ function syncKeys(current, pre) {
|
|
|
174
149
|
}
|
|
175
150
|
}
|
|
176
151
|
}
|
|
177
|
-
|
|
178
152
|
function _diff(current, pre, path, result) {
|
|
179
153
|
if (current === pre) return;
|
|
180
154
|
var rootCurrentType = type(current);
|
|
181
155
|
var rootPreType = type(pre);
|
|
182
|
-
|
|
183
156
|
if (rootCurrentType == OBJECTTYPE) {
|
|
184
157
|
if (rootPreType != OBJECTTYPE || Object.keys(current).length < Object.keys(pre).length) {
|
|
185
158
|
setResult(result, path, current);
|
|
@@ -189,7 +162,6 @@ function _diff(current, pre, path, result) {
|
|
|
189
162
|
var preValue = pre[key];
|
|
190
163
|
var currentType = type(currentValue);
|
|
191
164
|
var preType = type(preValue);
|
|
192
|
-
|
|
193
165
|
if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) {
|
|
194
166
|
if (currentValue != pre[key]) {
|
|
195
167
|
setResult(result, (path == '' ? '' : path + '.') + key, currentValue);
|
|
@@ -216,7 +188,6 @@ function _diff(current, pre, path, result) {
|
|
|
216
188
|
}
|
|
217
189
|
}
|
|
218
190
|
};
|
|
219
|
-
|
|
220
191
|
for (var key in current) {
|
|
221
192
|
_loop(key);
|
|
222
193
|
}
|
|
@@ -237,21 +208,17 @@ function _diff(current, pre, path, result) {
|
|
|
237
208
|
setResult(result, path, current);
|
|
238
209
|
}
|
|
239
210
|
}
|
|
240
|
-
|
|
241
211
|
function setResult(result, k, v) {
|
|
242
212
|
if (type(v) != FUNCTIONTYPE) {
|
|
243
213
|
result[k] = v;
|
|
244
214
|
}
|
|
245
215
|
}
|
|
246
|
-
|
|
247
216
|
function type(obj) {
|
|
248
217
|
return Object.prototype.toString.call(obj);
|
|
249
218
|
}
|
|
250
219
|
|
|
251
220
|
var _lifecycleMap;
|
|
252
|
-
|
|
253
221
|
var TaroLifeCycles;
|
|
254
|
-
|
|
255
222
|
(function (TaroLifeCycles) {
|
|
256
223
|
TaroLifeCycles["WillMount"] = "componentWillMount";
|
|
257
224
|
TaroLifeCycles["DidMount"] = "componentDidMount";
|
|
@@ -259,38 +226,27 @@ var TaroLifeCycles;
|
|
|
259
226
|
TaroLifeCycles["DidHide"] = "componentDidHide";
|
|
260
227
|
TaroLifeCycles["WillUnmount"] = "componentWillUnmount";
|
|
261
228
|
})(TaroLifeCycles || (TaroLifeCycles = {}));
|
|
262
|
-
|
|
263
229
|
var lifecycleMap = (_lifecycleMap = {}, _defineProperty__default["default"](_lifecycleMap, TaroLifeCycles.WillMount, ['created']), _defineProperty__default["default"](_lifecycleMap, TaroLifeCycles.DidMount, ['attached']), _defineProperty__default["default"](_lifecycleMap, TaroLifeCycles.DidShow, ['onShow']), _defineProperty__default["default"](_lifecycleMap, TaroLifeCycles.DidHide, ['onHide']), _defineProperty__default["default"](_lifecycleMap, TaroLifeCycles.WillUnmount, ['detached', 'onUnload']), _lifecycleMap);
|
|
264
230
|
var lifecycles = new Set(['ready']);
|
|
265
|
-
|
|
266
231
|
for (var key in lifecycleMap) {
|
|
267
232
|
var lifecycle = lifecycleMap[key];
|
|
268
233
|
lifecycle.forEach(function (l) {
|
|
269
234
|
return lifecycles.add(l);
|
|
270
235
|
});
|
|
271
236
|
}
|
|
272
|
-
|
|
273
237
|
var uniquePageLifecycle = ['onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onShareTimeline', 'onAddToFavorites', 'onPageScroll', 'onResize', 'onTabItemTap'];
|
|
274
238
|
var appOptions = ['onLaunch', 'onShow', 'onHide', 'onError', 'onPageNotFound', 'onUnhandledRejection', 'onThemeChange'];
|
|
275
239
|
|
|
276
240
|
/**
|
|
277
241
|
* Simple bind, faster than native
|
|
278
242
|
*/
|
|
279
|
-
function bind(fn
|
|
280
|
-
/*: Function */
|
|
281
|
-
, ctx
|
|
282
|
-
/*: Object */
|
|
283
|
-
) {
|
|
243
|
+
function bind(fn /*: Function */, ctx /*: Object */) {
|
|
284
244
|
if (!fn) return false;
|
|
285
|
-
|
|
286
245
|
function boundFn(a) {
|
|
287
|
-
var l
|
|
288
|
-
/*: number */
|
|
289
|
-
= arguments.length;
|
|
246
|
+
var l /*: number */ = arguments.length;
|
|
290
247
|
return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
248
|
+
}
|
|
249
|
+
// record original fn length
|
|
294
250
|
boundFn._length = fn.length;
|
|
295
251
|
return boundFn;
|
|
296
252
|
}
|
|
@@ -301,40 +257,30 @@ function safeGet(obj, propsArg, defaultValue) {
|
|
|
301
257
|
if (!obj) {
|
|
302
258
|
return defaultValue;
|
|
303
259
|
}
|
|
304
|
-
|
|
305
260
|
var props, prop;
|
|
306
|
-
|
|
307
261
|
if (Array.isArray(propsArg)) {
|
|
308
262
|
props = propsArg.slice(0);
|
|
309
263
|
}
|
|
310
|
-
|
|
311
264
|
if (typeof propsArg === 'string') {
|
|
312
265
|
props = propsArg.replace(/\[(.+?)\]/g, '.$1');
|
|
313
266
|
props = props.split('.');
|
|
314
267
|
}
|
|
315
|
-
|
|
316
268
|
if (_typeof__default["default"](propsArg) === 'symbol') {
|
|
317
269
|
props = [propsArg];
|
|
318
270
|
}
|
|
319
|
-
|
|
320
271
|
if (!Array.isArray(props)) {
|
|
321
272
|
throw new Error('props arg must be an array, a string or a symbol');
|
|
322
273
|
}
|
|
323
|
-
|
|
324
274
|
while (props.length) {
|
|
325
275
|
prop = props.shift();
|
|
326
|
-
|
|
327
276
|
if (!obj) {
|
|
328
277
|
return defaultValue;
|
|
329
278
|
}
|
|
330
|
-
|
|
331
279
|
obj = obj[prop];
|
|
332
|
-
|
|
333
280
|
if (obj === undefined) {
|
|
334
281
|
return defaultValue;
|
|
335
282
|
}
|
|
336
283
|
}
|
|
337
|
-
|
|
338
284
|
return obj;
|
|
339
285
|
}
|
|
340
286
|
function safeSet(obj, props, value) {
|
|
@@ -342,39 +288,30 @@ function safeSet(obj, props, value) {
|
|
|
342
288
|
props = props.replace(/\[(.+?)\]/g, '.$1');
|
|
343
289
|
props = props.split('.');
|
|
344
290
|
}
|
|
345
|
-
|
|
346
291
|
if (_typeof__default["default"](props) === 'symbol') {
|
|
347
292
|
props = [props];
|
|
348
293
|
}
|
|
349
|
-
|
|
350
294
|
var lastProp = props.pop();
|
|
351
|
-
|
|
352
295
|
if (!lastProp) {
|
|
353
296
|
return false;
|
|
354
297
|
}
|
|
355
|
-
|
|
356
298
|
var thisProp;
|
|
357
|
-
|
|
358
299
|
while (thisProp = props.shift()) {
|
|
359
300
|
if (typeof obj[thisProp] === 'undefined') {
|
|
360
301
|
obj[thisProp] = {};
|
|
361
|
-
}
|
|
302
|
+
}
|
|
303
|
+
// 直接按路径修改 this.state 可能会导致 nextProps 也被修改
|
|
362
304
|
// 因此按路径寻找时,每一层都复制一遍
|
|
363
|
-
|
|
364
|
-
|
|
365
305
|
if (Array.isArray(obj[thisProp])) {
|
|
366
306
|
obj[thisProp] = _toConsumableArray__default["default"](obj[thisProp]);
|
|
367
307
|
} else if (_typeof__default["default"](obj[thisProp]) === 'object') {
|
|
368
308
|
obj[thisProp] = Object.assign({}, obj[thisProp]);
|
|
369
309
|
}
|
|
370
|
-
|
|
371
310
|
obj = obj[thisProp];
|
|
372
|
-
|
|
373
311
|
if (!obj || _typeof__default["default"](obj) !== 'object') {
|
|
374
312
|
return false;
|
|
375
313
|
}
|
|
376
314
|
}
|
|
377
|
-
|
|
378
315
|
obj[lastProp] = value;
|
|
379
316
|
return true;
|
|
380
317
|
}
|
|
@@ -386,22 +323,18 @@ function flattenBehaviors(behavior, behaviorMap) {
|
|
|
386
323
|
if (typeof behavior === 'string') {
|
|
387
324
|
return report("\u4E0D\u652F\u6301\u4F7F\u7528\u5185\u7F6E Behavior: [".concat(behavior, "]"));
|
|
388
325
|
}
|
|
389
|
-
|
|
390
326
|
var subBehaviors = behavior.behaviors;
|
|
391
|
-
|
|
392
327
|
if (subBehaviors === null || subBehaviors === void 0 ? void 0 : subBehaviors.length) {
|
|
393
328
|
subBehaviors.forEach(function (subBehavior) {
|
|
394
329
|
return flattenBehaviors(subBehavior, behaviorMap);
|
|
395
330
|
});
|
|
396
331
|
}
|
|
397
|
-
|
|
398
332
|
Object.keys(behavior).forEach(function (key) {
|
|
399
333
|
// 不支持的属性
|
|
400
334
|
if (nonsupport.has(key)) {
|
|
401
335
|
var advise = nonsupport.get(key);
|
|
402
336
|
return report(advise);
|
|
403
337
|
}
|
|
404
|
-
|
|
405
338
|
if (behaviorMap.has(key)) {
|
|
406
339
|
var list = behaviorMap.get(key);
|
|
407
340
|
var value = behavior[key];
|
|
@@ -411,15 +344,10 @@ function flattenBehaviors(behavior, behaviorMap) {
|
|
|
411
344
|
}
|
|
412
345
|
|
|
413
346
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
414
|
-
|
|
415
347
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
416
|
-
|
|
417
348
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
418
|
-
|
|
419
349
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf__default["default"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default["default"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default["default"](this, result); }; }
|
|
420
|
-
|
|
421
350
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
422
|
-
|
|
423
351
|
function defineGetter(component, key, getter) {
|
|
424
352
|
Object.defineProperty(component, key, {
|
|
425
353
|
enumerable: true,
|
|
@@ -428,71 +356,55 @@ function defineGetter(component, key, getter) {
|
|
|
428
356
|
if (getter === 'props') {
|
|
429
357
|
return component.props;
|
|
430
358
|
}
|
|
431
|
-
|
|
432
359
|
return Object.assign(Object.assign({}, component.state), component.props);
|
|
433
360
|
}
|
|
434
361
|
});
|
|
435
362
|
}
|
|
436
|
-
|
|
437
363
|
function isFunction(o) {
|
|
438
364
|
return typeof o === 'function';
|
|
439
365
|
}
|
|
440
|
-
|
|
441
366
|
function withWeapp(weappConf) {
|
|
442
367
|
var isApp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
443
|
-
|
|
444
368
|
if (_typeof__default["default"](weappConf) === 'object' && Object.keys(weappConf).length === 0) {
|
|
445
369
|
report('withWeapp 请传入“App/页面/组件“的配置对象。如果原生写法使用了基类,请将基类组合后的配置对象传入,详情请参考文档。');
|
|
446
370
|
}
|
|
447
|
-
|
|
448
371
|
return function (ConnectComponent) {
|
|
449
372
|
var _a;
|
|
450
|
-
|
|
451
373
|
var behaviorMap = new Map([['properties', []], ['data', []], ['methods', []], ['created', []], ['attached', []], ['ready', []], ['detached', []]]);
|
|
452
374
|
var behaviorProperties = {};
|
|
453
|
-
|
|
454
375
|
if ((_a = weappConf.behaviors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
455
376
|
var behaviors = weappConf.behaviors;
|
|
456
377
|
behaviors.forEach(function (behavior) {
|
|
457
378
|
return flattenBehaviors(behavior, behaviorMap);
|
|
458
379
|
});
|
|
459
380
|
var propertiesList = behaviorMap.get('properties');
|
|
460
|
-
|
|
461
381
|
if (propertiesList.length) {
|
|
462
382
|
propertiesList.forEach(function (property) {
|
|
463
383
|
Object.assign(behaviorProperties, property);
|
|
464
384
|
});
|
|
465
385
|
Object.keys(behaviorProperties).forEach(function (propName) {
|
|
466
386
|
var propValue = behaviorProperties[propName];
|
|
467
|
-
|
|
468
387
|
if (!weappConf.properties) {
|
|
469
388
|
weappConf.properties = {};
|
|
470
389
|
}
|
|
471
|
-
|
|
472
390
|
if (!weappConf.properties.hasOwnProperty(propName)) {
|
|
473
391
|
if (propValue && _typeof__default["default"](propValue) === 'object' && propValue.value) {
|
|
474
392
|
propValue.value = clone(propValue.value);
|
|
475
393
|
}
|
|
476
|
-
|
|
477
394
|
weappConf.properties[propName] = propValue;
|
|
478
395
|
}
|
|
479
396
|
});
|
|
480
397
|
}
|
|
481
398
|
}
|
|
482
|
-
|
|
483
399
|
var BaseComponent = /*#__PURE__*/function (_ConnectComponent) {
|
|
484
400
|
_inherits__default["default"](BaseComponent, _ConnectComponent);
|
|
485
|
-
|
|
486
401
|
var _super = _createSuper(BaseComponent);
|
|
487
|
-
|
|
488
402
|
function BaseComponent(props) {
|
|
489
403
|
var _this;
|
|
490
|
-
|
|
491
404
|
_classCallCheck__default["default"](this, BaseComponent);
|
|
492
|
-
|
|
493
405
|
_this = _super.call(this, props);
|
|
494
|
-
_this._observeProps = [];
|
|
495
|
-
|
|
406
|
+
_this._observeProps = [];
|
|
407
|
+
// mixins 可以多次调用生命周期
|
|
496
408
|
_this.willMounts = [];
|
|
497
409
|
_this.didMounts = [];
|
|
498
410
|
_this.didHides = [];
|
|
@@ -501,57 +413,44 @@ function withWeapp(weappConf) {
|
|
|
501
413
|
_this.eventDestroyList = [];
|
|
502
414
|
_this.current = runtime.getCurrentInstance();
|
|
503
415
|
_this.taroGlobalData = Object.create(null);
|
|
504
|
-
|
|
505
416
|
_this.safeExecute = function (func) {
|
|
506
417
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
507
418
|
args[_key - 1] = arguments[_key];
|
|
508
419
|
}
|
|
509
|
-
|
|
510
420
|
if (isFunction(func)) func.apply(_assertThisInitialized__default["default"](_this), args);
|
|
511
421
|
};
|
|
512
|
-
|
|
513
422
|
_this.setData = function (obj, callback) {
|
|
514
423
|
var oldState;
|
|
515
|
-
|
|
516
424
|
if (_this.observers && Object.keys(Object.keys(_this.observers))) {
|
|
517
425
|
oldState = clone(_this.state);
|
|
518
426
|
}
|
|
519
|
-
|
|
520
427
|
Object.keys(obj).forEach(function (key) {
|
|
521
428
|
safeSet(_this.state, key, obj[key]);
|
|
522
429
|
});
|
|
523
|
-
|
|
524
430
|
_this.setState(_this.state, function () {
|
|
525
431
|
_this.triggerObservers(_this.state, oldState);
|
|
526
|
-
|
|
527
432
|
if (callback) {
|
|
528
433
|
callback.call(_assertThisInitialized__default["default"](_this));
|
|
529
434
|
}
|
|
530
435
|
});
|
|
531
436
|
};
|
|
532
|
-
|
|
533
437
|
_this.triggerEvent = function (eventName, detail, options) {
|
|
534
438
|
if (options) {
|
|
535
439
|
report('triggerEvent 不支持事件选项。');
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
|
|
440
|
+
}
|
|
441
|
+
// eventName support kebab case
|
|
539
442
|
if (eventName.match(/[a-z]+-[a-z]+/g)) {
|
|
540
443
|
eventName = eventName.replace(/-[a-z]/g, function (match) {
|
|
541
444
|
return match[1].toUpperCase();
|
|
542
445
|
});
|
|
543
446
|
}
|
|
544
|
-
|
|
545
447
|
var props = _this.props;
|
|
546
448
|
var dataset = {};
|
|
547
|
-
|
|
548
449
|
for (var key in props) {
|
|
549
450
|
if (!key.startsWith('data-')) continue;
|
|
550
451
|
dataset[key.replace(/^data-/, '')] = props[key];
|
|
551
452
|
}
|
|
552
|
-
|
|
553
453
|
var func = props["on".concat(eventName[0].toUpperCase()).concat(eventName.slice(1))];
|
|
554
|
-
|
|
555
454
|
if (isFunction(func)) {
|
|
556
455
|
func.call(_assertThisInitialized__default["default"](_this), {
|
|
557
456
|
type: eventName,
|
|
@@ -567,7 +466,6 @@ function withWeapp(weappConf) {
|
|
|
567
466
|
});
|
|
568
467
|
}
|
|
569
468
|
};
|
|
570
|
-
|
|
571
469
|
_this.hasBehavior = _this.componentMethodsProxy('hasBehavior');
|
|
572
470
|
_this.createSelectorQuery = _this.componentMethodsProxy('createSelectorQuery');
|
|
573
471
|
_this.createIntersectionObserver = _this.componentMethodsProxy('createIntersectionObserver');
|
|
@@ -579,21 +477,18 @@ function withWeapp(weappConf) {
|
|
|
579
477
|
_this.clearAnimation = _this.componentMethodsProxy('clearAnimation');
|
|
580
478
|
_this.setUpdatePerformanceListener = _this.componentMethodsProxy('setUpdatePerformanceListener');
|
|
581
479
|
_this.state = _this.state || {};
|
|
582
|
-
|
|
583
480
|
_this.init(weappConf);
|
|
584
|
-
|
|
585
481
|
defineGetter(_assertThisInitialized__default["default"](_this), 'data', 'state');
|
|
586
482
|
defineGetter(_assertThisInitialized__default["default"](_this), 'properties', 'props');
|
|
587
483
|
return _this;
|
|
588
484
|
}
|
|
589
|
-
|
|
590
485
|
_createClass__default["default"](BaseComponent, [{
|
|
591
486
|
key: "initProps",
|
|
592
487
|
value: function initProps(props) {
|
|
593
488
|
for (var propKey in props) {
|
|
594
489
|
if (props.hasOwnProperty(propKey)) {
|
|
595
|
-
var propValue = props[propKey];
|
|
596
|
-
|
|
490
|
+
var propValue = props[propKey];
|
|
491
|
+
// propValue 可能是 null, 构造函数, 对象
|
|
597
492
|
if (propValue && !isFunction(propValue)) {
|
|
598
493
|
if (propValue.observer) {
|
|
599
494
|
this._observeProps.push({
|
|
@@ -609,20 +504,16 @@ function withWeapp(weappConf) {
|
|
|
609
504
|
key: "init",
|
|
610
505
|
value: function init(options) {
|
|
611
506
|
var _this2 = this;
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
507
|
+
var _a, _b, _c;
|
|
508
|
+
// 处理 Behaviors
|
|
616
509
|
if ((_a = options.behaviors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
617
510
|
var _iterator = _createForOfIteratorHelper(behaviorMap.entries()),
|
|
618
|
-
|
|
619
|
-
|
|
511
|
+
_step;
|
|
620
512
|
try {
|
|
621
513
|
var _loop = function _loop() {
|
|
622
514
|
var _step$value = _slicedToArray__default["default"](_step.value, 2),
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
515
|
+
key = _step$value[0],
|
|
516
|
+
list = _step$value[1];
|
|
626
517
|
switch (key) {
|
|
627
518
|
case 'created':
|
|
628
519
|
case 'attached':
|
|
@@ -634,7 +525,6 @@ function withWeapp(weappConf) {
|
|
|
634
525
|
break;
|
|
635
526
|
}
|
|
636
527
|
};
|
|
637
|
-
|
|
638
528
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
639
529
|
_loop();
|
|
640
530
|
}
|
|
@@ -644,71 +534,56 @@ function withWeapp(weappConf) {
|
|
|
644
534
|
_iterator.f();
|
|
645
535
|
}
|
|
646
536
|
}
|
|
647
|
-
|
|
648
537
|
for (var confKey in options) {
|
|
649
538
|
// 不支持的属性
|
|
650
539
|
if (nonsupport.has(confKey)) {
|
|
651
540
|
var advise = nonsupport.get(confKey);
|
|
652
541
|
report(advise);
|
|
653
542
|
}
|
|
654
|
-
|
|
655
543
|
var confValue = options[confKey];
|
|
656
|
-
|
|
657
544
|
switch (confKey) {
|
|
658
545
|
case 'behaviors':
|
|
659
546
|
break;
|
|
660
|
-
|
|
661
547
|
case 'data':
|
|
662
548
|
{
|
|
663
549
|
if (isApp) {
|
|
664
550
|
this[confKey] = confValue;
|
|
665
|
-
|
|
666
551
|
if (!appOptions.includes(confKey)) {
|
|
667
552
|
this.defineProperty(this.taroGlobalData, confKey, this);
|
|
668
553
|
}
|
|
669
554
|
} else {
|
|
670
555
|
this.state = Object.assign(Object.assign({}, confValue), this.state);
|
|
671
556
|
}
|
|
672
|
-
|
|
673
557
|
break;
|
|
674
558
|
}
|
|
675
|
-
|
|
676
559
|
case 'properties':
|
|
677
560
|
this.initProps(Object.assign(behaviorProperties, confValue));
|
|
678
561
|
break;
|
|
679
|
-
|
|
680
562
|
case 'methods':
|
|
681
563
|
for (var key in confValue) {
|
|
682
564
|
var method = confValue[key];
|
|
683
565
|
this[key] = bind(method, this);
|
|
684
566
|
}
|
|
685
|
-
|
|
686
567
|
break;
|
|
687
|
-
|
|
688
568
|
case 'lifetimes':
|
|
689
569
|
for (var _key2 in confValue) {
|
|
690
570
|
this.initLifeCycles(_key2, confValue[_key2]);
|
|
691
571
|
}
|
|
692
|
-
|
|
693
572
|
break;
|
|
694
|
-
|
|
695
573
|
case 'pageLifetimes':
|
|
696
574
|
for (var _key3 in confValue) {
|
|
697
575
|
var cb = confValue[_key3];
|
|
698
|
-
|
|
699
576
|
switch (_key3) {
|
|
700
577
|
case 'show':
|
|
701
578
|
{
|
|
702
579
|
this.initLifeCycleListener('show', cb);
|
|
703
580
|
break;
|
|
704
581
|
}
|
|
705
|
-
|
|
706
582
|
case 'hide':
|
|
707
583
|
{
|
|
708
584
|
this.initLifeCycleListener('hide', cb);
|
|
709
585
|
break;
|
|
710
586
|
}
|
|
711
|
-
|
|
712
587
|
case 'resize':
|
|
713
588
|
{
|
|
714
589
|
report('不支持组件所在页面的生命周期 pageLifetimes.resize。');
|
|
@@ -716,67 +591,53 @@ function withWeapp(weappConf) {
|
|
|
716
591
|
}
|
|
717
592
|
}
|
|
718
593
|
}
|
|
719
|
-
|
|
720
594
|
break;
|
|
721
|
-
|
|
722
595
|
default:
|
|
723
596
|
if (lifecycles.has(confKey)) {
|
|
724
597
|
// 优先使用 lifetimes 中定义的生命周期
|
|
725
598
|
if ((_b = options.lifetimes) === null || _b === void 0 ? void 0 : _b[confKey]) {
|
|
726
599
|
break;
|
|
727
600
|
}
|
|
728
|
-
|
|
729
601
|
var lifecycle = options[confKey];
|
|
730
602
|
this.initLifeCycles(confKey, lifecycle);
|
|
731
603
|
} else if (isFunction(confValue)) {
|
|
732
604
|
this[confKey] = bind(confValue, this);
|
|
733
|
-
|
|
734
605
|
if (isApp && !appOptions.includes(confKey)) {
|
|
735
606
|
this.defineProperty(this.taroGlobalData, confKey, this);
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
|
|
607
|
+
}
|
|
608
|
+
// 原生页面和 Taro 页面中共计只能定义一次的生命周期
|
|
739
609
|
if (uniquePageLifecycle.includes(confKey) && ConnectComponent.prototype[confKey]) {
|
|
740
610
|
report("\u751F\u547D\u5468\u671F ".concat(confKey, " \u5DF2\u5728\u539F\u751F\u90E8\u5206\u8FDB\u884C\u5B9A\u4E49\uFF0CReact \u90E8\u5206\u7684\u5B9A\u4E49\u5C06\u4E0D\u4F1A\u88AB\u6267\u884C\u3002"));
|
|
741
611
|
}
|
|
742
612
|
} else {
|
|
743
613
|
this[confKey] = confValue;
|
|
744
|
-
|
|
745
614
|
if (isApp && !appOptions.includes(confKey)) {
|
|
746
615
|
this.defineProperty(this.taroGlobalData, confKey, this);
|
|
747
616
|
}
|
|
748
617
|
}
|
|
749
|
-
|
|
750
618
|
break;
|
|
751
619
|
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
|
|
620
|
+
}
|
|
621
|
+
// 处理 Behaviors
|
|
755
622
|
if ((_c = options.behaviors) === null || _c === void 0 ? void 0 : _c.length) {
|
|
756
623
|
(function () {
|
|
757
624
|
var behaviorData = {};
|
|
758
625
|
var methods = {};
|
|
759
|
-
|
|
760
626
|
var _iterator2 = _createForOfIteratorHelper(behaviorMap.entries()),
|
|
761
|
-
|
|
762
|
-
|
|
627
|
+
_step2;
|
|
763
628
|
try {
|
|
764
629
|
var _loop2 = function _loop2() {
|
|
765
630
|
var _step2$value = _slicedToArray__default["default"](_step2.value, 2),
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
631
|
+
key = _step2$value[0],
|
|
632
|
+
list = _step2$value[1];
|
|
769
633
|
switch (key) {
|
|
770
634
|
case 'data':
|
|
771
635
|
[].concat(_toConsumableArray__default["default"](list), [_this2.state]).forEach(function (dataObject, index) {
|
|
772
636
|
Object.keys(dataObject).forEach(function (dataKey) {
|
|
773
637
|
var value = dataObject[dataKey];
|
|
774
638
|
var preValue = behaviorData[dataKey];
|
|
775
|
-
|
|
776
639
|
var valueType = _typeof__default["default"](value);
|
|
777
|
-
|
|
778
640
|
var preValueType = _typeof__default["default"](preValue);
|
|
779
|
-
|
|
780
641
|
if (valueType === 'object') {
|
|
781
642
|
if (!value) {
|
|
782
643
|
behaviorData[dataKey] = value;
|
|
@@ -793,7 +654,6 @@ function withWeapp(weappConf) {
|
|
|
793
654
|
});
|
|
794
655
|
_this2.state = behaviorData;
|
|
795
656
|
break;
|
|
796
|
-
|
|
797
657
|
case 'methods':
|
|
798
658
|
list.forEach(function (methodsObject) {
|
|
799
659
|
Object.assign(methods, methodsObject);
|
|
@@ -805,12 +665,10 @@ function withWeapp(weappConf) {
|
|
|
805
665
|
}
|
|
806
666
|
});
|
|
807
667
|
break;
|
|
808
|
-
|
|
809
668
|
default:
|
|
810
669
|
break;
|
|
811
670
|
}
|
|
812
671
|
};
|
|
813
|
-
|
|
814
672
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
815
673
|
_loop2();
|
|
816
674
|
}
|
|
@@ -830,17 +688,14 @@ function withWeapp(weappConf) {
|
|
|
830
688
|
var advise = nonsupport.get(lifecycleName);
|
|
831
689
|
return report(advise);
|
|
832
690
|
}
|
|
833
|
-
|
|
834
691
|
if (lifecycleName === 'ready') {
|
|
835
692
|
// 如果组件是延时渲染的,页面 onReady 的事件已经 emit 了,因此使用 componentDidMount + nextTick 模拟
|
|
836
693
|
if (this.current.page.onReady.called) {
|
|
837
694
|
this.didMounts.push(function () {
|
|
838
695
|
var _this3 = this;
|
|
839
|
-
|
|
840
696
|
for (var _len2 = arguments.length, args = new Array(_len2), _key4 = 0; _key4 < _len2; _key4++) {
|
|
841
697
|
args[_key4] = arguments[_key4];
|
|
842
698
|
}
|
|
843
|
-
|
|
844
699
|
taro.nextTick(function () {
|
|
845
700
|
if (isFunction(lifecycle)) {
|
|
846
701
|
lifecycle.apply(_this3, args);
|
|
@@ -853,34 +708,28 @@ function withWeapp(weappConf) {
|
|
|
853
708
|
} else {
|
|
854
709
|
for (var lifecycleKey in lifecycleMap) {
|
|
855
710
|
var cycleNames = lifecycleMap[lifecycleKey];
|
|
856
|
-
|
|
857
711
|
if (cycleNames.indexOf(lifecycleName) !== -1) {
|
|
858
712
|
switch (lifecycleKey) {
|
|
859
713
|
case TaroLifeCycles.DidHide:
|
|
860
714
|
this.didHides.push(lifecycle);
|
|
861
715
|
break;
|
|
862
|
-
|
|
863
716
|
case TaroLifeCycles.DidMount:
|
|
864
717
|
this.didMounts.push(lifecycle);
|
|
865
718
|
break;
|
|
866
|
-
|
|
867
719
|
case TaroLifeCycles.DidShow:
|
|
868
720
|
this.didShows.push(lifecycle);
|
|
869
721
|
break;
|
|
870
|
-
|
|
871
722
|
case TaroLifeCycles.WillMount:
|
|
872
723
|
this.willMounts.push(lifecycle);
|
|
873
724
|
break;
|
|
874
|
-
|
|
875
725
|
case TaroLifeCycles.WillUnmount:
|
|
876
726
|
this.willUnmounts.push(lifecycle);
|
|
877
727
|
break;
|
|
878
728
|
}
|
|
879
729
|
}
|
|
880
730
|
}
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
|
|
731
|
+
}
|
|
732
|
+
// mixins 不会覆盖已经设置的生命周期,加入到 this 是为了形如 this.created() 的调用
|
|
884
733
|
if (!isFunction(this[lifecycleName])) {
|
|
885
734
|
this[lifecycleName] = lifecycle;
|
|
886
735
|
}
|
|
@@ -892,8 +741,8 @@ function withWeapp(weappConf) {
|
|
|
892
741
|
var router = this.current.router;
|
|
893
742
|
var lifecycleName = "on".concat(name[0].toUpperCase()).concat(name.slice(1));
|
|
894
743
|
cb = cb.bind(this);
|
|
895
|
-
(router === null || router === void 0 ? void 0 : router[lifecycleName]) && taro.eventCenter.on(router[lifecycleName], cb);
|
|
896
|
-
|
|
744
|
+
(router === null || router === void 0 ? void 0 : router[lifecycleName]) && taro.eventCenter.on(router[lifecycleName], cb);
|
|
745
|
+
// unMount 时需要取消事件监听
|
|
897
746
|
this.eventDestroyList.push(function () {
|
|
898
747
|
return taro.eventCenter.off(router[lifecycleName], cb);
|
|
899
748
|
});
|
|
@@ -904,7 +753,6 @@ function withWeapp(weappConf) {
|
|
|
904
753
|
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key5 = 1; _key5 < _len3; _key5++) {
|
|
905
754
|
args[_key5 - 1] = arguments[_key5];
|
|
906
755
|
}
|
|
907
|
-
|
|
908
756
|
for (var i = 0; i < funcs.length; i++) {
|
|
909
757
|
var func = funcs[i];
|
|
910
758
|
this.safeExecute.apply(this, [func].concat(args));
|
|
@@ -914,17 +762,15 @@ function withWeapp(weappConf) {
|
|
|
914
762
|
key: "triggerPropertiesObservers",
|
|
915
763
|
value: function triggerPropertiesObservers(prevProps, nextProps) {
|
|
916
764
|
var _this4 = this;
|
|
917
|
-
|
|
918
765
|
this._observeProps.forEach(function (_ref) {
|
|
919
766
|
var key = _ref.name,
|
|
920
|
-
|
|
767
|
+
observer = _ref.observer;
|
|
921
768
|
var prop = prevProps === null || prevProps === void 0 ? void 0 : prevProps[key];
|
|
922
|
-
var nextProp = nextProps[key];
|
|
923
|
-
|
|
769
|
+
var nextProp = nextProps[key];
|
|
770
|
+
// 小程序是深比较不同之后才 trigger observer
|
|
924
771
|
if (!isEqual(prop, nextProp)) {
|
|
925
772
|
if (typeof observer === 'string') {
|
|
926
773
|
var ob = _this4[observer];
|
|
927
|
-
|
|
928
774
|
if (isFunction(ob)) {
|
|
929
775
|
ob.call(_this4, nextProp, prop, key);
|
|
930
776
|
}
|
|
@@ -938,45 +784,35 @@ function withWeapp(weappConf) {
|
|
|
938
784
|
key: "triggerObservers",
|
|
939
785
|
value: function triggerObservers(current, prev) {
|
|
940
786
|
var observers = this.observers;
|
|
941
|
-
|
|
942
787
|
if (observers == null) {
|
|
943
788
|
return;
|
|
944
789
|
}
|
|
945
|
-
|
|
946
790
|
if (Object.keys(observers).length === 0) {
|
|
947
791
|
return;
|
|
948
792
|
}
|
|
949
|
-
|
|
950
793
|
var result = diff(current, prev);
|
|
951
794
|
var resultKeys = Object.keys(result);
|
|
952
|
-
|
|
953
795
|
if (resultKeys.length === 0) {
|
|
954
796
|
return;
|
|
955
797
|
}
|
|
956
|
-
|
|
957
798
|
for (var observerKey in observers) {
|
|
958
799
|
if (/\*\*/.test(observerKey)) {
|
|
959
800
|
report('数据监听器 observers 不支持使用通配符 **。');
|
|
960
801
|
continue;
|
|
961
802
|
}
|
|
962
|
-
|
|
963
803
|
var keys = observerKey.split(',').map(function (k) {
|
|
964
804
|
return k.trim();
|
|
965
805
|
});
|
|
966
806
|
var isModified = false;
|
|
967
|
-
|
|
968
807
|
for (var i = 0; i < keys.length; i++) {
|
|
969
808
|
var key = keys[i];
|
|
970
|
-
|
|
971
809
|
for (var j = 0; j < resultKeys.length; j++) {
|
|
972
810
|
var resultKey = resultKeys[j];
|
|
973
|
-
|
|
974
811
|
if (resultKey.startsWith(key) || key.startsWith(resultKey) && key.endsWith(']')) {
|
|
975
812
|
isModified = true;
|
|
976
813
|
}
|
|
977
814
|
}
|
|
978
815
|
}
|
|
979
|
-
|
|
980
816
|
if (isModified) {
|
|
981
817
|
observers[observerKey].apply(this, keys.map(function (key) {
|
|
982
818
|
return safeGet(current, key);
|
|
@@ -1003,22 +839,19 @@ function withWeapp(weappConf) {
|
|
|
1003
839
|
value: function privateStopNoop() {
|
|
1004
840
|
var e;
|
|
1005
841
|
var fn;
|
|
1006
|
-
|
|
1007
842
|
if (arguments.length === 2) {
|
|
1008
843
|
fn = arguments.length <= 0 ? undefined : arguments[0];
|
|
1009
844
|
e = arguments.length <= 1 ? undefined : arguments[1];
|
|
1010
845
|
} else if (arguments.length === 1) {
|
|
1011
846
|
e = arguments.length <= 0 ? undefined : arguments[0];
|
|
1012
847
|
}
|
|
1013
|
-
|
|
1014
848
|
if (e.type === 'touchmove') {
|
|
1015
849
|
report('catchtouchmove 转换后只能停止回调函数的冒泡,不能阻止滚动穿透。如要阻止滚动穿透,可以手动给编译后的 View 组件加上 catchMove 属性');
|
|
1016
850
|
}
|
|
1017
|
-
|
|
1018
851
|
e.stopPropagation();
|
|
1019
852
|
isFunction(fn) && fn(e);
|
|
1020
|
-
}
|
|
1021
|
-
|
|
853
|
+
}
|
|
854
|
+
// ================ React 生命周期 ================
|
|
1022
855
|
}, {
|
|
1023
856
|
key: "componentWillMount",
|
|
1024
857
|
value: function componentWillMount() {
|
|
@@ -1060,8 +893,8 @@ function withWeapp(weappConf) {
|
|
|
1060
893
|
this.triggerObservers(nextProps, this.props);
|
|
1061
894
|
this.triggerPropertiesObservers(this.props, nextProps);
|
|
1062
895
|
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentWillReceiveProps", this));
|
|
1063
|
-
}
|
|
1064
|
-
|
|
896
|
+
}
|
|
897
|
+
// ================ 小程序 App, Page, Component 实例属性与方法 ================
|
|
1065
898
|
}, {
|
|
1066
899
|
key: "is",
|
|
1067
900
|
get: function get() {
|
|
@@ -1081,10 +914,8 @@ function withWeapp(weappConf) {
|
|
|
1081
914
|
key: "componentMethodsProxy",
|
|
1082
915
|
value: function componentMethodsProxy(method) {
|
|
1083
916
|
var _this5 = this;
|
|
1084
|
-
|
|
1085
917
|
return function () {
|
|
1086
918
|
var page = _this5.current.page;
|
|
1087
|
-
|
|
1088
919
|
if (page === null || page === void 0 ? void 0 : page[method]) {
|
|
1089
920
|
return page[method].apply(page, arguments);
|
|
1090
921
|
} else {
|
|
@@ -1113,16 +944,12 @@ function withWeapp(weappConf) {
|
|
|
1113
944
|
report(nonsupport.get('groupSetData'));
|
|
1114
945
|
}
|
|
1115
946
|
}]);
|
|
1116
|
-
|
|
1117
947
|
return BaseComponent;
|
|
1118
948
|
}(ConnectComponent);
|
|
1119
|
-
|
|
1120
949
|
var props = weappConf.properties;
|
|
1121
|
-
|
|
1122
950
|
if (props) {
|
|
1123
951
|
for (var propKey in props) {
|
|
1124
952
|
var propValue = props[propKey];
|
|
1125
|
-
|
|
1126
953
|
if (propValue != null && !isFunction(propValue)) {
|
|
1127
954
|
if (propValue.value !== undefined) {
|
|
1128
955
|
// 如果是 null 也赋值到 defaultProps
|
|
@@ -1131,11 +958,9 @@ function withWeapp(weappConf) {
|
|
|
1131
958
|
}
|
|
1132
959
|
}
|
|
1133
960
|
}
|
|
1134
|
-
|
|
1135
961
|
var staticOptions = ['externalClasses', 'relations', 'options'];
|
|
1136
962
|
staticOptions.forEach(function (option) {
|
|
1137
963
|
var value = weappConf[option];
|
|
1138
|
-
|
|
1139
964
|
if (value != null) {
|
|
1140
965
|
BaseComponent[option] = value;
|
|
1141
966
|
}
|