详解 Vue2.0 模拟后台 JSON 数据
在 Vue2.0 环境中,可以通过以下步骤模拟后台数据交互:
- 安装 vue-resource:
npm install vue-resource --save - 在页面中引用 vue-resource
- 修改 webpack 配置文件 build/webpack.dev.conf.js,添加对 json-server 和 express 的配置
- 启动 json-server 服务:
json-server --watch db.json - 在 Vue 实例中使用 vue-resource 发起请求
文件大小:152.93KB
评论区