您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關如何實現layui頁面級彈出框的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
home/Index.cshtml
@{ ViewData["Title"] = "Home Page"; } <script> layui.use(['layer','form'], function(){ var $ = layui.jquery, layer = layui.layer; //獨立版的layer無需執行這一句 var form = layui.form; //觸發事件 var active = { test: function(){ layer.alert('你好么,體驗者'); } ,test2: function(){ layer.confirm('您是如何看待前端開發?', { btn: ['重要','奇葩'] //按鈕 }, function(){ layer.msg('的確很重要', {icon: 1}); }, function(){ layer.msg('也可以這樣', { time: 20000, //20s后自動關閉 btn: ['明白了', '知道了'] }); }); } ,test3: function(){ layer.msg('玩命提示中'); } ,test4: function(){ layer.tips('Hi,我是一個小提示', this, {tips: 1}); } ,test5: function(){ $('#test11111').html("加載中..."); layer.open({ title:'更新論壇信息', type: 1, //skin: 'layui-layer-rim', area: ['500px', '580px'], content: $('#test11111') }); $.get("@Url.Action("Index","Test")"+"?t="+(Math.random()), function(result){ $('#test11111').html(result); form.render(null,"first"); $("#dvName").html("mydiv11"); }); } ,test6: function(){ layer.open({ type: 2 ,content: 'http://fly.layui.com/' ,area: ['375px', '500px'] ,maxmin: true }); } ,test7: function(){ layer.prompt({title: '輸入任何口令,并確認', formType: 1}, function(pass, index){ layer.close(index); layer.prompt({title: '隨便寫點啥,并確認', formType: 2}, function(text, index){ layer.close(index); layer.msg('演示完畢!您的口令:'+ pass +'<br>您最后寫下了:'+text); }); }); } ,test8: function(){ layer.tab({ area: ['600px', '300px'], tab: [{ title: 'TAB1', content: '內容1' }, { title: 'TAB2', content: '內容2' }, { title: 'TAB3', content: '內容3' }] }); } }; $('.demo').on('click', function(){ var type = $(this).data('type'); active[type] ? active[type].call(this) : ''; }); }); </script> <div class="text-center"> <button class="layui-btn layui-btn-primary demo" data-type="test">Alert</button> <button class="layui-btn demo" data-type="test2">Confirm</button> <button class="layui-btn demo" data-type="test3">Msg</button> <button class="layui-btn demo" data-type="test4">Tips</button> <button class="layui-btn demo" data-type="test5">Page</button> <button class="layui-btn demo" data-type="test6">Iframe</button> <button class="layui-btn demo" data-type="test7">Prompt</button> <button class="layui-btn demo" data-type="test8">Tab</button> </div> <div id="test11111" > 加載中... </div>
TestController.cs
using Microsoft.AspNetCore.Mvc; using System; using System.Threading.Tasks; namespace layuidemo.Controllers { public class TestController : Controller { public async Task<IActionResult> Index() { await Task.Delay(TimeSpan.FromSeconds(5)); return View(); } } }
Test/Index.cshtml
@* For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 *@ @{ Layout = null; } <h2>HI world GGFLY</h2> <form class="layui-form layui-form-pane1" action="" lay-filter="first"> <div class="layui-form-item"> <label class="layui-form-label">輸入框</label> <div class="layui-input-block"> <input type="text" name="title" lay-verify="required|title" required placeholder="請輸入標題" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">手機</label> <div class="layui-input-block"> <input type="tel" name="phone" lay-verify="required|number" lay-verType="tips" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">郵箱</label> <div class="layui-input-block"> <input type="email" name="email" lay-verify="email" lay-verType="alert" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">密碼</label> <div class="layui-input-inline"> <input type="password" name="password" lay-verify="required|pass" placeholder="請輸入密碼" autocomplete="off" class="layui-input"> </div> <div class="layui-form-mid layui-word-aux">請務必填寫用戶名</div> </div> <div class="layui-form-item"> <div class="layui-inline"> <label class="layui-form-label">范圍</label> <div class="layui-input-inline" > <input type="text" name="price_min" placeholder="¥" autocomplete="off" class="layui-input"> </div> <div class="layui-form-mid">-</div> <div class="layui-input-inline" > <input type="text" name="price_max" placeholder="¥" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-inline"> <label class="layui-form-label">行內表單</label> <div class="layui-input-block"> <select name="quiz" lay-verify="required" lay-verType="tips"> <option value="">請選擇問題</option> <option value="0">你工作的第一個城市</option> <option value="1" disabled>你的工號</option> <option value="2">你最喜歡的老師</option> </select> </div> </div> <div class="layui-inline"> <label class="layui-form-label">select分組</label> <div class="layui-input-block"> <select name="quiz" lay-filter="quiz"> <option value="">請選擇問題</option> <optgroup label="城市記憶"> <option value="0">你工作的第一個城市</option> </optgroup> <optgroup label="學生時代"> <option value="1" disabled>你的工號</option> <option value="2">你最喜歡的老師</option> </optgroup> </select> </div> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">選擇框</label> <div class="layui-input-block"> <select name="interest" lay-filter="interest"> <option value=""></option> <option value="0">寫作</option> <option value="1">閱讀</option> <option value="2">游戲</option> <option value="3">音樂</option> <option value="4">旅行</option> </select> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">搜索選擇框</label> <div class="layui-input-inline"> <select name="interest-search" lay-filter="interest-search" lay-search> <option value="">請搜索</option> <option value="寫作">寫作</option> <option value="閱讀" disabled>閱讀</option> <option value="游戲" disabled>游戲</option> <option value="音樂">音樂</option> <option value="旅行">旅行</option> <option value="讀書">讀書</option> <option value="1">layer</option> <option value="2" disabled>laydate</option> <option value="3">3</option> <option value="4">layim</option> <option value="5">laypage</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> </select> </div> </div> <div class="layui-form-item" pane> <label class="layui-form-label">復選框</label> <div class="layui-input-block"> <input type="checkbox" name="like[write]" title="寫作"> <input type="checkbox" name="like[read]" title="閱讀"> <input type="checkbox" name="like[game]" title="游戲" disabled> </div> </div> <div class="layui-form-item" pane> <label class="layui-form-label">原始復選框</label> <div class="layui-input-block"> <input type="checkbox" name="like1[write]" lay-skin="primary" title="寫作"> <input type="checkbox" name="like1[read]" lay-skin="primary" title="閱讀"> <input type="checkbox" name="like1[game]" lay-skin="primary" title="游戲" disabled> </div> </div> <div class="layui-form-item" pane> <label class="layui-form-label">開關關</label> <div class="layui-input-block"> <input type="checkbox" name="close" lay-skin="switch" title="開關"> </div> </div> <div class="layui-form-item" pane> <label class="layui-form-label">開關開</label> <div class="layui-input-block"> <input type="checkbox" checked name="open" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF"> <input type="checkbox" name="open2" lay-skin="switch" lay-filter="switchTest" lay-text="已綁定|綁定"> </div> </div> <div class="layui-form-item" pane> <label class="layui-form-label">單選框</label> <div class="layui-input-block"> <input type="radio" name="sex" value="男" title="男"> <input type="radio" name="sex" value="女" title="女" checked> <input type="radio" name="sex" value="中型" title="中" disabled> </div> </div> <div class="layui-form-item" pane> <label class="layui-form-label">單選框</label> <div class="layui-input-block"> <input type="radio" name="sex.id" value="男" title="男"> <input type="radio" name="sex.id" value="女" title="女" checked> <input type="radio" name="sex.id" value="中型" title="中"> </div> </div> <div class="layui-form-item layui-form-text"> <label class="layui-form-label">請填寫描述</label> <div class="layui-input-block"> <textarea placeholder="請輸入內容" class="layui-textarea" name="desc"></textarea> </div> </div> <div class="layui-form-item"> <div class="layui-input-block"> <button class="layui-btn" lay-submit lay-filter="*">立即提交</button> <button type="reset" class="layui-btn layui-btn-primary">重置</button> </div> </div> </form> <form class="layui-form layui-form-pane1" action="" lay-filter="second"> <div class="layui-form-item"> <label class="layui-form-label">輸入框</label> <div class="layui-input-block"> <input type="text" name="title" lay-verify="required|title" required placeholder="請輸入標題" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">手機</label> <div class="layui-input-block"> <input type="tel" name="phone" lay-verify="required|number" lay-verType="tips" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">郵箱</label> <div class="layui-input-block"> <input type="email" name="email" lay-verify="email" lay-verType="alert" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">密碼</label> <div class="layui-input-inline"> <input type="password" name="password" lay-verify="required|pass" placeholder="請輸入密碼" autocomplete="off" class="layui-input"> </div> <div class="layui-form-mid layui-word-aux">請務必填寫用戶名</div> </div> <div class="layui-form-item"> <div class="layui-inline"> <label class="layui-form-label">范圍</label> <div class="layui-input-inline" > <input type="text" name="price_min" placeholder="¥" autocomplete="off" class="layui-input"> </div> <div class="layui-form-mid">-</div> <div class="layui-input-inline" > <input type="text" name="price_max" placeholder="¥" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-inline"> <label class="layui-form-label">行內表單</label> <div class="layui-input-block"> <select name="quiz" lay-verify="required" lay-verType="tips"> <option value="">請選擇問題</option> <option value="0">你工作的第一個城市</option> <option value="1" disabled>你的工號</option> <option value="2">你最喜歡的老師</option> </select> </div> </div> <div class="layui-inline"> <label class="layui-form-label">select分組</label> <div class="layui-input-block"> <select name="quiz" lay-filter="quiz"> <option value="">請選擇問題</option> <optgroup label="城市記憶"> <option value="0">你工作的第一個城市</option> </optgroup> <optgroup label="學生時代"> <option value="1" disabled>你的工號</option> <option value="2">你最喜歡的老師</option> </optgroup> </select> </div> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">選擇框</label> <div class="layui-input-block"> <select name="interest" lay-filter="interest"> <option value=""></option> <option value="0">寫作</option> <option value="1">閱讀</option> <option value="2">游戲</option> <option value="3">音樂</option> <option value="4">旅行</option> </select> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">搜索選擇框</label> <div class="layui-input-inline"> <select name="interest-search" lay-filter="interest-search" lay-search> <option value="">請搜索</option> <option value="寫作">寫作</option> <option value="閱讀" disabled>閱讀</option> <option value="游戲" disabled>游戲</option> <option value="音樂">音樂</option> <option value="旅行">旅行</option> <option value="讀書">讀書</option> <option value="1">layer</option> <option value="2" disabled>laydate</option> <option value="3">3</option> <option value="4">layim</option> <option value="5">laypage</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> </select> </div> </div> <div class="layui-form-item" pane> <label class="layui-form-label">復選框</label> <div class="layui-input-block"> <input type="checkbox" name="like[write]" title="寫作"> <input type="checkbox" name="like[read]" title="閱讀"> <input type="checkbox" name="like[game]" title="游戲" disabled> </div> </div> <div class="layui-form-item" pane> <label class="layui-form-label">原始復選框</label> <div class="layui-input-block"> <input type="checkbox" name="like1[write]" lay-skin="primary" title="寫作"> <input type="checkbox" name="like1[read]" lay-skin="primary" title="閱讀"> <input type="checkbox" name="like1[game]" lay-skin="primary" title="游戲" disabled> </div> </div> <div class="layui-form-item" pane> <label class="layui-form-label">開關關</label> <div class="layui-input-block"> <input type="checkbox" name="close" lay-skin="switch" title="開關"> </div> </div> <div class="layui-form-item" pane> <label class="layui-form-label">開關開</label> <div class="layui-input-block"> <input type="checkbox" checked name="open" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF"> <input type="checkbox" name="open2" lay-skin="switch" lay-filter="switchTest" lay-text="已綁定|綁定"> </div> </div> <div class="layui-form-item" pane> <label class="layui-form-label">單選框</label> <div class="layui-input-block"> <input type="radio" name="sex" value="男" title="男"> <input type="radio" name="sex" value="女" title="女" checked> <input type="radio" name="sex" value="中型" title="中" disabled> </div> </div> <div class="layui-form-item" pane> <label class="layui-form-label">單選框</label> <div class="layui-input-block"> <input type="radio" name="sex.id" value="男" title="男"> <input type="radio" name="sex.id" value="女" title="女" checked> <input type="radio" name="sex.id" value="中型" title="中"> </div> </div> <div class="layui-form-item layui-form-text"> <label class="layui-form-label">請填寫描述</label> <div class="layui-input-block"> <textarea placeholder="請輸入內容" class="layui-textarea" name="desc"></textarea> </div> </div> <div class="layui-form-item"> <div class="layui-input-block"> <button class="layui-btn" lay-submit lay-filter="*">立即提交</button> <button type="reset" class="layui-btn layui-btn-primary">重置</button> </div> </div> </form> <div id="dvName"></div>
運行效果:lay-filter="first" 會重新渲染表單,lay-filter="second" 不會重新渲染
感謝各位的閱讀!關于“如何實現layui頁面級彈出框”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。