1 | function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
2 |
|
3 | function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4 |
|
5 | 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); }
|
6 |
|
7 | function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
8 |
|
9 | function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
10 |
|
11 | 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; }
|
12 |
|
13 | function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
14 |
|
15 | import { nextTick } from 'vue';
|
16 | import { getOptionProps } from './props-util';
|
17 | export default {
|
18 | methods: {
|
19 | setState: function setState() {
|
20 | var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
21 | var callback = arguments.length > 1 ? arguments[1] : undefined;
|
22 | var newState = typeof state === 'function' ? state(this, this.$props) : state;
|
23 |
|
24 | if (this.getDerivedStateFromProps) {
|
25 | var s = this.getDerivedStateFromProps(getOptionProps(this), _extends(_extends({}, this), newState));
|
26 |
|
27 | if (s === null) {
|
28 | return;
|
29 | } else {
|
30 | newState = _extends(_extends({}, newState), s || {});
|
31 | }
|
32 | }
|
33 |
|
34 | _extends(this, newState);
|
35 |
|
36 | if (this._.isMounted) {
|
37 | this.$forceUpdate();
|
38 | }
|
39 |
|
40 | nextTick(function () {
|
41 | callback && callback();
|
42 | });
|
43 | },
|
44 | __emit: function __emit() {
|
45 |
|
46 | var args = [].slice.call(arguments, 0);
|
47 | var eventName = args[0];
|
48 | eventName = "on".concat(eventName[0].toUpperCase()).concat(eventName.substring(1));
|
49 | var event = this.$props[eventName] || this.$attrs[eventName];
|
50 |
|
51 | if (args.length && event) {
|
52 | if (Array.isArray(event)) {
|
53 | for (var i = 0, l = event.length; i < l; i++) {
|
54 | event[i].apply(event, _toConsumableArray(args.slice(1)));
|
55 | }
|
56 | } else {
|
57 | event.apply(void 0, _toConsumableArray(args.slice(1)));
|
58 | }
|
59 | }
|
60 | }
|
61 | }
|
62 | }; |
\ | No newline at end of file |