具体步骤
1、首先将.json文件数据放置到项目根目录下的 public文件夹下
2、然后到需要使用的地方通过 axios 获取本地数据,代码如下:
getMenuData() {
axios.get('/menu.json')
.then(result => {
console.log('getMenuData', result)
})
.catch(error => {
console.log(error)
})
}
最终获取到的数据如下