vue cli3 configure the ports and setting cross-domain, transmission parameters with axios post request

1, man of few words said, directly Code

The root directory is created vue.config.js

module.exports = {
    devServer: {
      port: 3000, // port
      proxy: {
        '/api': {
            target: 'http://192.168.9.217:8999/',
            changeOrigin: true,
            ws: true,
            Pthriawrite: {
              '^/api': ''
            }
        }
    }
    },
    // lintOnSave: false // cancel eslint verification
  }
View Code

axios post parameter passing problem

methods:{
      getParent(){
          console.log(this.input);
         
          const params = new URLSearchParams();
          params.append('name', this.input);
          params.append('password', this.input1);
          this.$axios.post('api/user/login',params)
            .then(function (response) {
                console.log(response);
            })
            .catch(function (error) {
                console.log(error);
            });
      }
 },
View Code

About axios post request mass participation details of the problem

 

Guess you like

Origin www.cnblogs.com/xqhv587/p/11968514.html