日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

fastmock使用-只能模擬get請求

作者:頑強的小豆子 更新時間: 2022-07-10 編程語言

參考文檔:

Mock.js?使用格式

Syntax Specification · nuysoft/Mock Wiki · GitHub?對上面格式語法說明

1.結合參考文檔,將內容填寫到以下右側模板,重點關注 @cname等類似代碼

查看實例代碼無法打開,參考下面模板

{

  "code": "200",



  "data": {

    "studentlist|10-15":[{

    "id|+1":0,

    "name":"@cname",

    "age":"@integer(22,50)",

    "img":"@image('200x200', '#50B347', '#FFF', 'FastMock')",

    "city":"@city",

    "email":"@email"

  }]

  },



  "desc": "成功"

}

2.寫好接口以后,訪問的鏈接

用瀏覽器打開

https://www.fastmock.site/mock/6bdf1d792a7b22f797c0347fcdb8521e/study/studentList

3.通過jquery方式請求數據/get

<!DOCTYPE html>

<html>

    <head>

        <meta charset="UTF-8" />

        <title>jquery發送ajax請求</title>

        <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>

    </head>

    <body>

        <!-- 準備好一個容器-->

        <div id="root">

            <app></app>

        </div>

        <script type="text/javascript">

        $.get("https://www.fastmock.site/mock/6bdf1d792a7b22f797c0347fcdb8521e/study/studentList",function(res){

            console.log(res)

        })

    </script>

    </body>

    

    

</html>

原文鏈接:https://blog.csdn.net/qiuyushuofeng/article/details/125144500

欄目分類
最近更新