我正在使用 V-data-table 和 vuex 存储。以下是我如何配置 v-data-table 的要点
问题: 当我拖放 v-data-table 中的行时,我正在更新 vuex 存储(使用表行索引值更新数组中对象的索引值)。Vuex 正在正确更新,但在 v-data-table 中呈现的数据与它们在 vuex 状态存储中的顺序不一致
有人可以帮助我吗
我试图克服这个问题的最好方法是强制重新渲染 v-data-table 组件,但是当我这样做时,我不能再拖放了
使用以下模板强制渲染
<template>
<component-to-re-render :key="componentKey" />
</template>
// script
export default {
data() {
return {
componentKey: 0,
};
},
methods: {
forceRerender() {
this.componentKey += 1;
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Vue + Vuetify,我正在尝试在第一列中添加图像。
表格模板代码
<v-data-table
:headers="headers"
:items="desserts"
:search="search"
light
>
<template slot="items" slot-scope="props">
<td><img :src="props.item.name" style="width: 50px; height: 50px"></td>
<td class="text-xs-right">{{ props.item.calories }}</td>
<td class="text-xs-right">{{ props.item.fat }}</td>
<td class="text-xs-right">{{ props.item.carbs }}</td>
<td class="text-xs-right">{{ props.item.protein }}</td>
<td class="text-xs-right">{{ props.item.iron }}</td>
</template>
<v-alert slot="no-results" :value="true" dir="rtl" color="error" icon="warning">
{{ PRODUCTS_TABLE_TEXT.NO_RESULT }} "{{ search }}"
</v-alert>
</v-data-table>
Run Code Online (Sandbox Code Playgroud)
表脚本代码
data () {
return {
//TEXT
PRODUCTS_TABLE_TEXT: products_table_text,
//TABLE DATA
search: '',
headers: [
{
text: products_table_text.columns.IMAGE,
align: 'center',
sortable: false,
value: 'image' …Run Code Online (Sandbox Code Playgroud)