1. 在项目 src 目录中新建 data / text.json 文件,
test.json 文件内容:
2. 在项目配置文件 vue.config.js (vue/cli3+ 需要手动创建) 引入 text.json 文件(第一行)。
3. 在需要渲染 json 数据的组件中引入 axios :(组件路由: http://localhost:xxxx/home)
- 确保项目中已经安装了 axios (npm i axiuos -S)
【参考文章】:简述 [蒋蒋] vue-cli3本地模拟数据(一) https://www.jianshu.com/p/993383798f30