Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/389.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.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 promise处理程序Vue Js中放入多条语句_Javascript_Laravel_Vue.js - Fatal编程技术网

Javascript 无法在Axios promise处理程序Vue Js中放入多条语句

Javascript 无法在Axios promise处理程序Vue Js中放入多条语句,javascript,laravel,vue.js,Javascript,Laravel,Vue.js,我在我的Laravel项目中使用Vue Js,在那里我使用它进行POST调用。 但是,在处理承诺时,它工作正常。我有以下问题: axios.post('/customer/update',this.customer) .then(response =>( //this.customer = response.data.customer //if this line is uncommented, the scripts falls over

我在我的Laravel项目中使用Vue Js,在那里我使用它进行POST调用。 但是,在处理承诺时,它工作正常。我有以下问题:

      axios.post('/customer/update',this.customer)
      .then(response =>(
      //this.customer = response.data.customer //if this line is uncommented, the scripts falls over
      this.error.text = response.data.message
      )).then(response =>(
        this.error.show = true
      )).then(response =>(
        this.error.class = true
      )).catch(err => {
        console.log(err);
      })
    }
我必须将几个.then()链接在一起,以处理其中的每个单数语句。理想情况下,我想这样做:

      axios.post('/customer/update',this.customer)
      .then(response =>(
      this.customer = response.data.customer
      this.error.text = response.data.message
      this.error.show = true
      this.error.class = true
      )).catch(err => {
        console.log(err);
      })
    }
有什么想法吗?因为我根本不知道上面这些有什么问题。它应该能工作,但不能

我得到了错误

Uncaught SyntaxError: Unexpected token 'this'
哪个指向我创建的标签

    created(){
    this.greeting;
    console.log(this.customer)
  }

我猜你有打字错误,用括号代替花括号,应该如下所示

axios.post('/customer/update',this.customer)
。然后(响应=>{
this.customer=response.data.customer
this.error.text=response.data.message
this.error.show=true
this.error.class=true
})
.catch(错误=>{
控制台日志(err);
});