Answer the question
In order to leave comments, you need to log in
[ VUE ] How to pass a template to a component?
Hello,
I'm writing a bicycle - a component for displaying a grid.
grid.vue
<tbody>
<tr v-for="entry in filteredData"
@click="toggleSelected(entry._id, $event)"
:class="{ selected: selected.indexOf(entry._id) !== -1 }">
<td v-for="key in columns">
{{ entry[key['name']] }}
</td>
</tr>
</tbody>
const gridColumns = [
{ name: 'sku', sortable: true, label: 'SKU' },
{ name: 'price', sortable: true },
{ name: 'inStock', label: 'Available' }
]
{ name: 'inStock', label: 'Available', template: '<input type="checkbox" {{ entry[key["name"] == true ? 'checked' : '' }}' }
key['template']
render its content in the parent component, if it exists, and if not - ?
Thank you! {{ entry[key['name']] }}
Answer the question
In order to leave comments, you need to log in
read about slot
if you are not writing for self-study, there is vuetable2 awesome thing, flexible. there is an example of slots for buttons, etc.
It seems to me that you should not do this, you have data in an array, why mix it with a display template. Tweak the template itself so that it displays a checkbox if the column name is equal to inStock.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question