vue+post+get

// 1、直接使用axios发起get请求
    document.querySelector('#btn1').addEventListener('click', function() {
        axios({
            method: 'GET',
            url: '',
            params: { 
            }
        }).then(function(res) {
            console.log(res.data);
        })
    })
    // 2、直接使用axios发起post请求
    document.querySelector('#btn2').addEventListener('click', function() {
        axios({
            method: 'POST',
            url: '',
            data: { 
            }
        }).then(function(res) {
           //dosomething
        })
    })

  vue不支持ajax,使用独有的axios与后端交互

posted @ 2022-10-08 20:54  程序员亮亮丫!!  阅读(16)  评论(0编辑  收藏  举报