我在 Vue/Laravel 中创建我的第一个 CRUD,现在我尝试将创建发送到我的后端应用程序,这是我的代码:前端:async addDespesa() { let uri = "api/despesas/create"; const response = await axios.get(uri, this.despesa).then((response) => { this.$router.push({ name: "despesas" }); });},后端:public function create(){ //}在浏览器上检查时出错:>[vue-router] Route with name 'despesas' does not exist >Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/". at createRouterError at createNavigationDuplicatedErrorat HashHistory.confirmTransitionat HashHistory.transitionToat evalat HashHistory.pushat new Promise at VueRouter.pushat eval
1 回答
慕田峪7331174
TA贡献1828条经验 获得超13个赞
您的后端看起来不错,问题出在.then您的 Axios 调用部分:
this.$router.push({ name: "despesas" });
您应该检查您的前端路由(可能在名为 的文件中routes.js)并确保您有一个名为 的路由despesas。所以像这样:
let routes = [
{
'path': '/path/to/despesas',
'name': 'despesas',
component: require('./path/to/despesas-component').default
},
...
other routes
];
添加回答
举报
0/150
提交
取消