A_Fann 2021-04-08 08:34 采纳率: 90.9%
浏览 186
已采纳

有人给了我一个webapi接口要我写网页调用,请问一下怎么调用啊

有人给了我一个webapi接口要我写网页调用,请问一下怎么调用啊

 

  • 写回答

8条回答 默认 最新

  • Lazy33 2021-04-08 09:21
    关注
    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    
    </head>
    
    <body>
        <button onclick="Inter()"> 点击请求</button>
    
        <script>
            function Inter() {
                axios.get('xxxxxxxxxxxx')
                    .then(function (response) {
                        console.log(response);
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            }
        </script>
    </body>
    
    </html>
    

    axios举例,你就把地址填到我写的xxxxx哪里试一下

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(7条)

报告相同问题?