使用mockjs来模拟数据( Use mockjs to mock data. ) #2363
ZeronoFreya
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
在编写界面时会遇到界面元素会根据数据变化的情况,比如listview,模拟数据是个很好的方案,你可以直接写在html里,但很难维护。
使用模拟数据之前我一般这么获取数据:
很明显用浏览器开发无法得到数据。
使用mockjs前的准备
在
main.js里:调取数据:
我这里统一了返回值结构:
golang里也一样:
关于mockjs
克隆 https://github.com/ZeronoFreya/vite_mock_server
安装运行就可以了,一个简单的mock服务
使用方法参考
vite_mock_server/mock/demomockJs简单语法:
Beta Was this translation helpful? Give feedback.
All reactions