0
点赞
收藏
分享

微信扫一扫

Vue项目中获取本地的json文件数据

boomwu 2022-05-30 阅读 71

具体步骤

1、首先将.json文件数据放置到项目根目录下的 public文件夹下

Vue项目中获取本地的json文件数据_ios

Vue项目中获取本地的json文件数据_数据_02

2、然后到需要使用的地方通过 axios 获取本地数据,代码如下:

    getMenuData() {
axios.get('/menu.json')
.then(result => {
console.log('getMenuData', result)
})
.catch(error => {
console.log(error)
})
}

最终获取到的数据如下

Vue项目中获取本地的json文件数据_ios_03

 


举报

相关推荐

0 条评论