2018-01-12 08:10:41 +00:00
|
|
|
|
export default {
|
2018-12-27 14:14:32 +00: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 08:10:41 +00:00
|
|
|
|
methods: {
|
2019-01-12 03:33:27 +00:00
|
|
|
|
setState(state, callback) {
|
|
|
|
|
const newState = typeof state === 'function' ? state(this.$data, this.$props) : state;
|
2018-12-25 04:00:39 +00:00
|
|
|
|
// if (this.getDerivedStateFromProps) {
|
|
|
|
|
// Object.assign(newState, this.getDerivedStateFromProps(getOptionProps(this), { ...this.$data, ...newState }, true) || {})
|
|
|
|
|
// }
|
2019-01-12 03:33:27 +00:00
|
|
|
|
Object.assign(this.$data, newState);
|
2018-01-12 08:10:41 +00:00
|
|
|
|
this.$nextTick(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
|
callback && callback();
|
|
|
|
|
});
|
2018-01-12 08:10:41 +00:00
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
|
__emit() {
|
|
|
|
|
// 直接调用listeners,底层组件不需要vueTool记录events
|
|
|
|
|
const args = [].slice.call(arguments, 0);
|
|
|
|
|
const filterEvent = [];
|
|
|
|
|
const eventName = args[0];
|
2018-01-17 08:12:53 +00:00
|
|
|
|
if (args.length && this.$listeners[eventName]) {
|
|
|
|
|
if (filterEvent.includes(eventName)) {
|
2019-01-12 03:33:27 +00:00
|
|
|
|
this.$emit(eventName, ...args.slice(1));
|
2018-01-17 08:12:53 +00:00
|
|
|
|
} else {
|
2019-01-12 03:33:27 +00:00
|
|
|
|
this.$listeners[eventName](...args.slice(1));
|
2018-01-17 08:12:53 +00:00
|
|
|
|
}
|
2018-01-12 08:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
|
};
|