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");
},
然后就发生了图一的情况
现在没有解决 等到周一问一下老师



