You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
在编写界面时会遇到界面元素会根据数据变化的情况,比如listview,模拟数据是个很好的方案,你可以直接写在html里,但很难维护。
使用模拟数据之前我一般这么获取数据:
很明显用浏览器开发无法得到数据。
使用mockjs前的准备
在
main.js
里:调取数据:
我这里统一了返回值结构:
golang里也一样:
关于mockjs
克隆 https://github.com/ZeronoFreya/vite_mock_server
安装运行就可以了,一个简单的mock服务
使用方法参考
vite_mock_server/mock/demo
mockJs简单语法:
Beta Was this translation helpful? Give feedback.
All reactions