Laravel 8 上的 sweetalert 2 上未出现取消

如果用户想要提交批准,我希望弹出警报。然而,当在sweetalert上点击“提交”时,它只显示“正常”,没有取消选项。


如何让取消选项出现?


这是我的刀片脚本:


<form action="{{ route('Upload') }}" method="POST" enctype="multipart/form-data" id="form" class="formsubmit">

                                              @csrf

                                              <div class="form-group">

                                                  <label for="title">Title:</label>

                                                  <input type="text" class="form-control @error('title') is-invalid @enderror" id="title" placeholder="Enter Title" name="title" >

                                                  <!-- <span class="text-danger error-text judul_err"></span> -->

                                                  @error('title')

                                                    <div class="alert alert-danger mt-2">

                                                        {{ $message }}

                                                    </div>

                                                @enderror

                                              </div>

                                              <!-- <div class="form-group">

                                                        <b>Images</b><br/>

                                                        <input type="file" name="file">

                                                    </div> -->

                                            <div class="custom-file">

                                                <input type="file" class="custom-file-input @error('file') is-invalid @enderror" name="file">

                                                <label class="custom-file-label" for="file">Pilih Berkas Maks. 2 MB</label>

                                                @error('file')

                                                    <div class="alert alert-danger mt-2">

                                                        {{ $message }}


慕妹3146593
浏览 100回答 1
1回答

ITMISS

我假设您使用的是最新版本的 Sweet Alert,因为您使用的是最新的 Laravel。如果是这种情况,您需要将 javascript 更新为最新的 SweetAlert 方法。这已经过测试并可与最新版本的 jQuery 和 SweetAlert 配合使用。<!-- jQuery --><script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script><!-- sweetalert --><script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>$( document ).ready(function() {&nbsp; &nbsp; $('#form').submit(function (e) {&nbsp; &nbsp; &nbsp; &nbsp; e.preventDefault();&nbsp; &nbsp; &nbsp; &nbsp; swal({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; icon: "warning",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title: "Are you sure?",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text: "Do you want to submit and pay 10 Rupiah",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buttons: ["No, cancel pls!", "Yes, send it!"],&nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; &nbsp; &nbsp; .then((value) => {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log('form submitted');&nbsp; &nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; });});
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript