브라질 인사입니다! Axis를 사용하여 배열을 검색하여 Ajax 요청을 수행하려고하는데 결과가 항상 비어 있습니다. 재밌는 것은 똑같은 요청이 숙련공 팅커으로 잘 작동한다는 것입니다! 의 일부 코드를 보자 :AXIOS가 아약스 요청시 빈 배열을 반환합니다.
경로/web.php 파일을
Route::get('/trocaCarros/{id}', '[email protected]')->name('trocaCarros');
Vuejs 방법 :
methods: {
umaMarca() {
// alert(marca.value);
axios.get('/trocaCarros/' + marca.value).then(response => this.vitrine = response.data);
}
VitrineController.php
public function trocaCarros(Request $request)
{
$marca = $request->id;
$umaMarcaModelo = Modelo::where('marca_id','=', $marca);
return response()->json($umaMarcaModelo);
}
브라우저 응답은 다음과 같습니다
나는 어설프게에서 그것을했다 63,210{}
그러나, 그런 다음
Psy Shell v0.8.11 (PHP 7.1.6 — cli) by Justin Hileman
$marca = 212
=> 212
...
$modelo = App\Modelo::where('marca_id','=', $marca)->get();
나는 데이터베이스에있는 것처럼 같이, (6 개) 결과를 반환 :
=> Illuminate\Database\Eloquent\Collection {#994
all: [
App\Modelo {#995
id: 880011,
descricao: "Accord",
marca_id: "212",
categoria_id: "1",
ativo: 1,
created_at: "2017-08-03 18:35:19",
updated_at: "2017-08-03 19:41:36",
},
App\Modelo {#996
id: 880012,
descricao: "City",
marca_id: "212",
categoria_id: "1",
ativo: 1,
created_at: "2017-08-03 18:47:26",
updated_at: "2017-08-03 18:47:26",
},
... 외 4 명
아무도 내가 놓친 것을 아는가? 감사합니다.
는 잊어'->()는'처음 얻을? – kerbholz
예, 잊어 버렸습니다. Thakns –