【发布时间】:2020-03-04 07:56:49
【问题描述】:
在我的项目中,我想将一些 Ajax 加载的菜单项添加到 Vue 中的 CoreUI 侧边栏。我已经找到了一个可行的解决方案,但它有点 hacky 并且可能存在时间问题。因此,我想问您,是否有适当的或至少更好的解决方案。
我前几天也找到了this question,但还没有答案。
// main.js
new Vue({
el: '#app',
router,
icons,
template: '<App/>',
components: {
App
},
data: {
clientConfiguration: null
},
created: async function () {
let svcResult = await this.$http.get('Picking/ViewerSettings');
this.clientConfiguration = svcResult.data;
this.$children[0].$children[0].$children[0].$data.nav[0]._children[0].items =
svcResult.data.map(vc => ({
name: vc.name,
to: 'test/' + vc.name,
icon: 'cil-spreadsheet'
}));
}
})
// _nav.js
export default [
{
_name: 'CSidebarNav',
_children: [
{
_name: 'CSidebarNavDropdown',
name: 'Lists',
to: '/test',
icon: 'cil-list-numbered',
items: []
},
// ...
]
}
]
【问题讨论】:
标签: javascript vue.js axios core-ui