1 回答
TA贡献1856条经验 获得超11个赞
您可以为 javascript 使用字符串占位符。
<input type="hidden" id="_room_id" value="{{ $room->id }}">
<input type="hidden" id="_room_project_id" value="{{ $room->id_project }}">
let project_id = $('#_room_project_id').val(); // or document.getElementById('_room_project_id').value if you're not using JQuery
let id = $('#_room_id').val(); // or document.getElementById('_room_id').value if you're not using JQuery
let url = "{{ route('datatable.getaccess', [':project_id', ':id']) }}".replace(':project_id', project_id).replace(':id', id);
这看起来是错误的,但它可以工作,因为我们将字符串传递给路由助手(这反过来会产生一个字符串)
route('datatable.getaccess', [':project_id', ':id'])
// 'viewroom/:project_id/:id'
所以
let url = "{{ route('datatable.getaccess', [':project_id', ':id']) }}".replace(':project_id', project_id).replace(':id', id);
相当于
let url = "viewroom/:project_id/:id".replace(':project_id', project_id).replace(':id', id);
- 1 回答
- 0 关注
- 98 浏览
添加回答
举报