Javascript 拉拉维尔积垢Axios Vue
我正在Vue/Laravel中创建我的第一个CRUD,现在我正在尝试向我的后端应用程序发送一个CRUD,这是我的代码: 前端:Javascript 拉拉维尔积垢Axios Vue,javascript,vue.js,axios,Javascript,Vue.js,Axios,我正在Vue/Laravel中创建我的第一个CRUD,现在我正在尝试向我的后端应用程序发送一个CRUD,这是我的代码: 前端: async addDespesa() { let uri = "api/despesas/create"; const response = await axios.get(uri, this.despesa).then((response) => { this.$router.push({ name: "despes
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 createNavigationDuplicatedError
at HashHistory.confirmTransition
at HashHistory.transitionTo
at eval
at HashHistory.push
at new Promise
at VueRouter.push
at eval
您的后端看起来很好,问题出在
中。然后,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
];
请同时发布您的后端代码:)对于api/despesas/create
端点,允许使用哪些方法?是POST
其中一个端点错误。我更改了get的帖子,出现了另一个错误。我用我所有的前端、后端和错误代码编辑了这篇文章。这个错误意味着你还没有定义一个名为“despesas”的路由。检查路线定义是否具有名称
属性。