请我在 Laravel 控制器的数组中有一个返回值。我想在 Vue 模板中显示,但遇到了问题。我需要帮助。
public function search(Request $request)
{
$batchResults = \DB::table('patient')
->select('*')
->join('registrations', 'patient.patient_id', 'registrations.patient_id')
->where('patient.name', 'like', '%' . $request -> name . '%')
->whereBetween('registrations.created_at', [date($request->from), date($request->to)])
->get();
$search = $request -> name;
return [ $batchResults, $batchResults ];
我想在 vue 模板中显示[ $batchResults, $batchResults ] resut
这是 console.log 结果
(2) [Array(1), "James Asay", __ob__: Observer]
0: [{…}, __ob__: Observer]
1: "James Asaye"
length: 2
__ob__: Observer {value: Array(2), dep: Dep, vmCount: 0}
__proto__: Array
Vue 组件
searchBatch(){
axios.post('/search-results', this.form).then((res)=>{
this.batchResource = res.data
this.display = true
console.log(res.data)
})
}