代码如下。。。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>模拟数据</title>
</head>
<body>
<input type="text" class="username">
<input type="text" class="userpass">
<button>获取模拟数据</button>
</body>
</html>
<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="node_modules/mockjs/dist/mock.js"></script>
<script>
$(function(){
let Random=Mock.Random;
Mock.mock('www.aaa.com',{
'username':Random.cname(),
'userpass|100000-999999999':111111
});
$('button').click(function(){
$.ajax({
url:'www.aaa.com',
type:'get',
dataType:'json',
async:true,
success:function(data){
console.log(data);
$(".username").val(data.username);
$(".userpass").val(data.userpass);
}
})
})
});
</script>