vue cli3配置端口和設置跨域,用axios post請求傳參


1,話不多說,直接代碼

根目錄創建vue.config.js

module.exports = {
    devServer: {
      port: 3000, // 端口
      proxy: {
        '/api': {
            target: 'http://192.168.9.217:8999/',
            changeOrigin: true,
            ws: true,
            pathRewrite: {
              '^/api': ''
            }
        }
    }
    },
    // lintOnSave: false // 取消 eslint 驗證
  }
View Code

axios post傳參問題

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

關於axios post請求傳參問題詳情

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM