[Vuejs]-How to use Vue 3 slots as parameters without rendering it?

0👍

The problem that you don’t even use the reactivity of the props. My bet computed could suit you:

const props = defineProps({
    data: {
        type: Array,
        required: true,
    },
});

const dataTableStore = computed(() => ({

    // why these props? we have only props.data as declared in defineProps()
    orderAll: props.orderAll, 
    searchAll: props.searchAll,

    // not sure about that, you can't have multiple slots with the same name I guess
    // needs investigation
    columns: slots.default().map(s => {
        return {
            title: s.props.title,
            prop: s.props.prop ?? s.props.title,
            order: s.props.order ?? false,
            search: s.props.search ?? false,
            searchType: s.props['search-type'] ?? 'text',
            searchOptions: s.props['search-options'] ?? []
        };
    });
}));

Leave a comment