From the Bootstrap Vue table documentation it is possible to render data customized.
https://bootstrap-vue.org/docs/components/table#scoped-field-slots
The example shows the following template:
<template v-slot:cell(index)="data">
{{ data.index + 1 }}
</template>
I'm using PUG as a template language and I'm having some trouble with its syntax. I didn't find the correct way to "translate" the above example to PUG syntax.
This doesn't work because of the colon:
template(v-slot:cell(index)="data") {{ data.index + 1 }}
Also this does not seem to be correct:
template(v-slot(cell(index)="data")) {{ data.index + 1 }}
Update #1
This is my field definition:
fields: [
"index",
{
key: "name",
label: this.$t("document.name"),
sortable: true
}
]
And this is the template:
b-table#filesList(
v-if="list.length > 0"
:items="list"
:fields="fields"
stacked="md"
striped
responsive
)
template(v-slot:cell(index)="data") {{ data.index + 1 }}
This only shows an empty "Index" column. If I change the template to the deprected slot
and slot-scope
synctax it's working:
template(slot="index" slot-scope="data") {{ data.index + 1 }}
index
field, to your fields array? – Hiwsindex
field has been added. – Robert Strauch2.0.0-rc.x
? It has a different syntax than the current version for table slots.v-slot
also requires vuev2.6.x
, so make sure you have that installed. – Hiws"bootstrap-vue": "^2.0.0-rc.20","vue": "^2.6.6"
– Robert Strauch