<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

<input />
<script>


    $("#test").click(function () {
        //get
        axios.get('/user')
            .then(function (data) {
                console.log(data);
            })
            .catch(function (reason) {
                console.log(reason);
            })
        //get 带参数
        axios.get('/user', {
                params: {
                    ID: 12345
                }
            })
            .then(function (response) {
                console.log(response);
            })
            .catch(function (error) {
                console.log(error);
            })
            .then(function () {
                console.log('hello')
            });
        //post
        axios.post('/user', {
                firstName: 'Fred',
                lastName: 'Flintstone'
            })
            .then(function (response) {
                console.log(response);
            })
            .catch(function (error) {
                console.log(error);
            });
    })
</script>

  

相关文章:

  • 2021-09-27
  • 2021-10-10
  • 2022-01-10
  • 2021-06-09
  • 2022-12-23
  • 2021-05-27
  • 2021-12-04
  • 2021-03-31
猜你喜欢
  • 2021-07-14
  • 2022-01-08
  • 2022-12-23
  • 2022-01-08
  • 2021-10-17
  • 2022-12-23
  • 2021-11-02
相关资源
相似解决方案