ant-design-vue/components/vc-tabs/src/SaveRef.jsx

28 lines
550 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import PropTypes from '../../_util/vue-types';
export default {
props: {
children: PropTypes.func.def(() => null),
},
methods: {
getRef(name) {
return this[name];
},
saveRef(name) {
return node => {
if (node) {
this[name] = node;
}
};
},
},
render() {
// 每次都new一个新的function避免子节点不能重新渲染
const saveRef = name => this.saveRef(name);
const getRef = name => this.getRef(name);
return this.children(saveRef, getRef);
},
};