aios的基本使用

2018-10-06  本文已影响0人  1462a2c022bc

1) 发送get方式的请求

      // 不带参数

        axios.get('url').then((response) => {

            console.log(response)

        }).catch((err) => {

            console.log(err)

        })

        // 带参数 方式1

        axios.get('url?username=admin&password=123').then((response) => {

            console.log(response)

        }).catch((err) => {

            console.log(err)

        })

        // 带参数 方式2

        axios.get('url', {

            params: {

                username: "admin",

                password: 123

            }

        }).then((response) => {

            console.log(response)

        }).catch((err) => {

            console.log(err)

        })

    2) 发送post方式的请求

    axios.post('url', {

        username: "admin",

        password: 123

    })

    .then((response) => {

        console.log(response)

    })

    .catch(err => {

        console.log(err);

    })

上一篇 下一篇

猜你喜欢

热点阅读