Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.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
Php v-on处理程序中的错误(承诺/异步):";TypeError:无法读取属性';推动';“未定义”的定义;_Php_Laravel_Vue.js_Sql Insert - Fatal编程技术网

Php v-on处理程序中的错误(承诺/异步):";TypeError:无法读取属性';推动';“未定义”的定义;

Php v-on处理程序中的错误(承诺/异步):";TypeError:无法读取属性';推动';“未定义”的定义;,php,laravel,vue.js,sql-insert,Php,Laravel,Vue.js,Sql Insert,当我收到来自控制器的响应时,显示“推”的信息未定义 这是我的控制器 const res = await this.callApi('post','place_order',this.formItem) if(res.status == 200){ this.order.push(res.data) this.s("Order Successful !") this.formItem = {} } 检

当我收到来自控制器的响应时,显示“推”的信息未定义

这是我的控制器

const res = await this.callApi('post','place_order',this.formItem)
if(res.status == 200){
                this.order.push(res.data)
                this.s("Order Successful !")
                this.formItem = {}
}
检查“this.order”的类型。只能在阵列上工作

编辑:因为它表示“未定义”的“推送”,所以您还应该检查“this.order”是否真的定义了。

检查“this.order”的类型。只能在阵列上工作

编辑:因为它说“push”是“undefined”,所以您还应该检查“this.order”是否真的定义了

public function place_order(Request $request){
        $data = $request->all();
        $order= Order::create($data);

        return response()->json([
            'order' => $order,
            'success' => true
        ],200);
    }