<a title="删除" onclick="del(this,'{{url($route, [$id])}}')" href="javascript:;">
    <i class="layui-icon layui-icon-delete"></i>删除
</a>&nbsp;

@push('scripts')
    <script>
        /*用户-删除*/
        function del(obj, url) {
            layer.confirm('确认要删除吗？', function (index) {
                $.ajax({
                    url: url,
                    type: 'POST',
                    dataType: 'html',
                    data: {_method: "DELETE"}
                }).done((result) => {
                    //发异步，把数据提交给php
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!', {icon: 1, time: 1000});
                }).error(function () {
                    console.log("error");
                }).always(function () {
                });
            });
        }
    </script>
@endpush
