2018-01-12 16:10:41 +08:00
|
|
|
|
export default {
|
2018-12-27 22:14:32 +08:00
|
|
|
|
// directives: {
|
|
|
|
|
// ref: {
|
|
|
|
|
// bind: function (el, binding, vnode) {
|
|
|
|
|
// binding.value(vnode.componentInstance ? vnode.componentInstance : vnode.elm)
|
|
|
|
|
// },
|
|
|
|
|
// update: function (el, binding, vnode) {
|
|
|
|
|
// binding.value(vnode.componentInstance ? vnode.componentInstance : vnode.elm)
|
|
|
|
|
// },
|
|
|
|
|
// unbind: function (el, binding, vnode) {
|
|
|
|
|
// binding.value(null)
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// },
|
2018-01-12 16:10:41 +08:00
|
|
|
|
methods: {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
setState(state, callback) {
|
|
|
|
|
const newState = typeof state === 'function' ? state(this.$data, this.$props) : state;
|
2018-12-25 12:00:39 +08:00
|
|
|
|
// if (this.getDerivedStateFromProps) {
|
|
|
|
|
// Object.assign(newState, this.getDerivedStateFromProps(getOptionProps(this), { ...this.$data, ...newState }, true) || {})
|
|
|
|
|
// }
|
2019-01-12 11:33:27 +08:00
|
|
|
|
Object.assign(this.$data, newState);
|
2020-03-07 19:45:13 +08:00
|
|
|
|
this.$forceUpdate();
|
2018-01-12 16:10:41 +08:00
|
|
|
|
this.$nextTick(() => {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
callback && callback();
|
|
|
|
|
});
|
2018-01-12 16:10:41 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
__emit() {
|
|
|
|
|
// 直接调用listeners,底层组件不需要vueTool记录events
|
|
|
|
|
const args = [].slice.call(arguments, 0);
|
|
|
|
|
const eventName = args[0];
|
2020-03-29 16:07:02 +08:00
|
|
|
|
const event = this.$listeners[eventName];
|
|
|
|
|
if (args.length && event) {
|
|
|
|
|
if (Array.isArray(event)) {
|
|
|
|
|
for (let i = 0, l = event.length; i < l; i++) {
|
|
|
|
|
event[i](...args.slice(1));
|
|
|
|
|
}
|
2018-01-17 16:12:53 +08:00
|
|
|
|
} else {
|
2020-03-29 16:07:02 +08:00
|
|
|
|
event(...args.slice(1));
|
2018-01-17 16:12:53 +08:00
|
|
|
|
}
|
2018-01-12 16:10:41 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|