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