栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

2021年10月30日 axios请求的端口号与设置的端口号不同

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

2021年10月30日 axios请求的端口号与设置的端口号不同

Vue+SpringBoot项目
axios请求地址错误 全部都是404 请求了错误的网址
正确的那个请求也是axios,不过是写在.vue中的请求

getXianCha() {
      this.$http({
        method: "post",
        url: "/der/milkTea/queryByXianCha",
      }).then(
        (res) => {
          // this.$message.warning(JSON.stringify(res.data));
          this.result = res.data;
        },
        (error) => {
          console.log(" request error : " + error.response.status);
        }
      );
    },
   

返回的状态码是200 是正确的
错误的请求是写在store/index.js里的

state: {
    materialsState: [
      {
        index: 1,
        value: "pearl",
        text: "珍珠",
      },
    ],
    sugerStates: [
      {
        index: 1,
        value: "normal",
        text: "正常糖",
      },
    ],
    temperatureState: [
      {
        index: 4,
        value: "hot",
        text: "热",
      },
    ],
  },
  mutations: {
    updateMaterialsState(state, payload) {
      state.materialsState = payload;
    },
    updateSugerStates(state, payload) {
      state.sugerStates = payload;
    },
    updateTemperatureState(state, payload) {
      state.temperatureState = payload;
    },
  },
  actions: {
    getMaterialsState(context) {
      //this.$http  this.$message
      axios({
        method: "get",
        url: "/der/common/materialsState",

      }).then(
        (res) => {
          // Message.warning(JSON.stringify(res.data));
          context.commit("updateMaterialsState", res.data);
        },
        (error) => {
          console.log(" request error : " + error.response.status);
        }
      );
    },
    getSugerStates(context) {
      //this.$http  this.$message
      axios({
        method: "get",
        url: "/der/common/sugerState",
      }).then(
        (res) => {
          // Message.warning(JSON.stringify(res.data));
          context.commit("updateSugerStates", res.data);
        },
        (error) => {
          console.log(" request error : " + error.response.status);
        }
      );
    },
    getTemperatureState(context) {
      //this.$http  this.$message
      axios({
        method: "get",
        url: "/der/common/temperatureState",
      }).then(
        (res) => {
          // Message.warning(JSON.stringify(res.data));
          context.commit("updateTemperatureState", res.data);
        },
        (error) => {
          console.log(" request error : " + error.response.status);
        }
      );
    },
  },
  modules: {},
});

后端接口用swagger测试过了 没有任何问题
前端端口是8090 后端是9090
在Vue的根app组件里调用请求

created() {
    this.$store.dispatch("getMaterialsState");
    this.$store.dispatch("getTemperatureState");
    this.$store.dispatch("getSugerStates");
  },

然后就发生了图一的情况
现在没有解决 等到周一问一下老师

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/358160.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号