实际上,我需要重写/* Generate some random example data */
const types = ['A', 'B', 'C']
const items = [];
for(let i = 0; i < 15; i++) {
items.push({
type: types[i % 3],
id: i + 1,
random: Math.random()
})
}
new Vue({
el: '#app',
computed: {
groupedItems() {
const groups = {};
this.items.forEach(item => {
if(groups[item.type]) {
groups[item.type].push(item);
} else {
groups[item.type] = [item];
}
});
return groups;
}
},
data() {
return {
items: items,
fields: ['type', 'id', 'random']
}
}
})
的某些功能,
为此,我正在计划提供<link href="https://unpkg.com/bootstrap@4.5.0/dist/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://unpkg.com/bootstrap-vue@2.15.0/dist/bootstrap-vue.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.js"></script>
<script src="https://unpkg.com/bootstrap-vue@2.15.0/dist/bootstrap-vue.js"></script>
<div id="app">
<b-card no-body class="mb-1" v-for="(group, type) in groupedItems">
<b-card-header header-tag="header" class="p-0" role="tab">
<b-button block v-b-toggle="`accordion-${type}`" variant="primary">
Type {{ type }}
</b-button>
</b-card-header>
<b-collapse :id="`accordion-${type}`" accordion="table-accordion" role="tabpanel">
<b-table :fields="fields" :items="group"></b-table>
</b-collapse>
</b-card>
</div>
接口的自定义实现。
所以这里想知道如何将这个Custom实现注入到我的环境中。目前,仅在添加/* Generate some random example data */
const types = ['A', 'B', 'C']
const items = [];
for(let i = 0; i < 30; i++) {
items.push({
type: types[i % 3],
group: i % 9,
id: i + 1,
random: Math.random()
})
}
new Vue({
el: '#app',
computed: {
groupedItems() {
const groups = {};
this.items.forEach(item => {
if(!groups[item.type]) groups[item.type] = {};
if(groups[item.type][item.group]) {
groups[item.type][item.group].push(item);
} else {
groups[item.type][item.group] = [item];
}
});
return groups;
}
},
data() {
return {
items: items,
fields: ['type', 'id', 'random']
}
}
})
注释(与我们对customErrorHandler所做的相同)之后,我的自定义实现仍无法执行。