我在 url 地址 ../quote 处有一个列表页面视图。我正在加载包含详细信息的页面,我有地址 url ../quote-detail/35,其中数字是任何 id。加载任何页面后,它返回一个带有前缀 ../**quote-detail/**view 的地址,这是错误的,没有前缀 /quote-detail/ 应该是正确的。
我的部分 web.php:
Route::post('/update-data', [App\Http\Controllers\DataController::class, 'updateData']);
Route::group(['prefix'=>'quote-detail'], function () {
Route::get('/{id}', [App\Http\Controllers\QuoteController::class, 'quoteDetail']);
});
使用ajax打开刀片的报价详细信息:
function editFunc(id) {
var url = "{{ 'quote-new' }}";
$.ajax({
headers: {
'X-CSRF-Token': '{{ csrf_token() }}',
},
type:"GET",
url: url,
data: { id: id },
dataType: 'json',
success: function(res){
window.location.href = res.url;
},
error: function(){
alert("failure From php side!!! ");
}
});
}
控制器:
public function new(Request $request)
{
$where = $request->id;
return response()->json(['url'=>url('quote-detail', ['id' => $where])]);
}
开放型材刀片:
<a class="dropdown-item" href="profile">
它在您的案例中附加了 href,因为您没有在前面使用
/
。尝试使用
<a class="dropdown-item" href="/profile">