Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 拉拉维尔积垢Axios Vue_Javascript_Vue.js_Axios - Fatal编程技术网

Javascript 拉拉维尔积垢Axios Vue

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

我正在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: "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”的路由。检查路线定义是否具有
名称
属性。