ant-design-vue/components/_util/BaseMixin.js

44 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export default {
// 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)
// },
// },
// },
methods: {
setState(state, callback) {
const newState = typeof state === 'function' ? state(this.$data, this.$props) : state;
// if (this.getDerivedStateFromProps) {
// Object.assign(newState, this.getDerivedStateFromProps(getOptionProps(this), { ...this.$data, ...newState }, true) || {})
// }
Object.assign(this.$data, newState);
this.$forceUpdate();
this.$nextTick(() => {
callback && callback();
});
},
__emit() {
// 直接调用listeners底层组件不需要vueTool记录events
const args = [].slice.call(arguments, 0);
const eventName = args[0];
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));
}
} else {
event(...args.slice(1));
}
}
},
},
};