iview/src/components/select/functional-options.vue

33 lines
972 B
Vue
Raw Normal View History

2019-08-27 09:42:40 +08:00
<script>
const returnArrayFn = () => [];
export default {
props: {
options: {
type: Array,
default: returnArrayFn
},
slotOptions: {
type: Array,
default: returnArrayFn
},
slotUpdateHook: {
type: Function,
default: () => {}
}
2019-08-27 09:42:40 +08:00
},
// if use functional, there will be memory leaks
// functional: true,
render(h) {
2019-08-27 09:42:40 +08:00
// to detect changes in the $slot children/options we do this hack
// so we can trigger the parents computed properties and have everything reactive
// although $slot.default is not
if (this.slotOptions !== this.$parent.$slots.default) this.slotUpdateHook();
return h('ul', [
this.$slots.default,
this.options
]);
2019-08-27 09:42:40 +08:00
}
};
</script>