alertmsg 变量值_layer弹出层框架alert与msg详解

论坛 期权论坛     
选择匿名的用户   2021-5-30 00:14   240   0
<div style="font-size:16px;">
<p>layer---&gt;web弹层组件</p>
<p align="center"><img alt="a7708f6d52dbef837aef1334e38fbe79.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-1cc87098448d9e66aeeacce65df05f57.png"></p>
<p align="center"><img alt="b39d88bb7c0a4930444383fc42ca72cb.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-7c929535d95b9446629ae5538eb3927f.png"></p>
<p align="center"><img alt="7102a266c1d0899f1b63cfaf6ab970b2.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-4e5b4c7885e220df96d9b20fb704f1bf.png"></p>
<p align="center"><img alt="bc365122c35105a7804c564a79db21a7.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-d7910038fec553c9bc186ddea2b79756.png"></p>
<p align="center"><img alt="9afd7ce6357cba41ff824a2f574e605f.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-92d82d55db3c29dc53334160aefdfbbc.png"></p>
<p align="center"><img alt="a06e56c708a77e23c5316751b8269539.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-cdc301d181601dae24b6a0fcb8485816.png"></p>
<p>代码:</p>
<p>1 layer.alert(&#39;见到你真的很高兴&#39;, {icon: 6});</p>
<p>这是一个最简单的弹出层,可根据icon配置左边的图标</p>
<p>通常情况下,除了弹窗之外我们一般都会有对按钮做回调处理的一些操作</p>
<p>如图:</p>
<p align="center"><img alt="f38b6c6e907819bf88c33f3b28830e0b.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-8997c831e3e626df88500421b00b96d7.png"></p>
<p>1 layer.alert(&#39;墨绿风格,点击确认看深蓝&#39;, {<!-- --></p>
<p>2 skin: &#39;layui-layer-molv&#39; //样式类名 自定义样式</p>
<p>3 ,closeBtn: 1 // 是否显示关闭按钮</p>
<p>4 ,anim: 1 //动画类型</p>
<p>5 ,btn: [&#39;重要&#39;,&#39;奇葩&#39;] //按钮</p>
<p>6 ,icon: 6 // icon</p>
<p>7 ,yes:function(){<!-- --></p>
<p>8 layer.msg(&#39;按钮1&#39;)</p>
<p>9 }</p>
<p>10 ,btn2:function(){<!-- --></p>
<p>11 layer.msg(&#39;按钮2&#39;)</p>
<p>12 }});</p>
<p>13</p>
<p align="center"><img alt="d16c39a5a76edf4577048cf53526d1e4.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-54d993be52ffb273f64a3c7704ddba57.png"></p>
<p align="center"><img alt="a4b5c0e4fd1b5beeb1e1ad8ece0e7c4b.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-0022c315426a96fedad419f26412852d.png"></p>
<p>code:</p>
<p>1 layer.msg(&#39;大部分参数都是可以公用的<br>合理搭配,展示不一样的风格&#39;, {<!-- --></p>
<p>2 time: 2000, //2s后自动关闭</p>
<p>3 btn: [&#39;明白了&#39;, &#39;知道了&#39;, &#39;哦&#39;]</p>
<p>4 });</p>
<p>回调的例子:</p>
<p align="center"><img alt="ef68c488ea9f43b39db03ee4d8782031.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-a60fc7defd5cfbac1237f6ddebfdb8ab.png"></p>
<p align="center"><img alt="1349a3ca53e1ede8f8998702e9505380.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-99c731a22a5568c87b2c608ba24fc237.png"></p>
<p>code:</p>
<p>1 layer.msg(&#39;也可以这样&#39;, {<!-- --></p>
<p>2 btn: [&#39;明白了&#39;, &#39;知道了&#39;]</p>
<p>3 ,yes: function(index, layero){<!-- --></p>
<p>4 layer.msg(&#34;按钮1回调,参数是:&#34;&#43;index)</p>
<p>5 }</p>
<p>6 ,btn2: function(index, layero){<!-- --></p>
<p>7 //按钮【按钮二】的回调</p>
<p>8 layer.msg(&#34;按钮2回调,参数是:&#34;&#43;index)</p>
<p>9 return false //开启该代码可禁止点击该按钮关闭</p>
<p>10 }</p>
<p>11 });</p>
<p>open方式</p>
<p align="center"><img alt="df9d723abb21b7ec15d33c96919f7256.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-d1f2d36a439ebaaef96da6c76061485a.png"></p>
<p>code</p>
<p>1 layer.open({<!-- --></p>
<p>2 type: 1</p>
<p>3 ,title: &#34;open方式弹出层&#34; //不显示标题栏 title : false/标题</p>
<p>4 ,closeBtn: true</p>
<p>5 ,area: &#39;300px;&#39;</p>
<p>6 ,shade: 0.8</p>
<p>7 ,id: &#39;LAY_layuipro&#39; //设定一个id,防止重复弹出</p>
<p>8 ,resize: false</p>
<p>9 ,btn: [&#39;火速围观&#39;, &#39;残忍拒绝&#39;]</p>
<p>10 ,btnAlign: &#39;c&#39;</p>
<p>11 ,moveType: 1 //拖拽模式,0或者1</p>
<p>12 ,content: &#39;</p>
<div style="line-height:22px;color:#fff;font-weight:300;">
  内容
  <br>内容
</div>&#39;
<p>13 ,success: function(layero){<!-- --></p>
<p>14 var btn &#61; layero.find(&#39;.layui-layer-btn&#39;);</p>
<p>15 btn.find(&#39;.layui-layer-btn0&#39;).attr({<!-- --></p>
<p>16 href: &#39;http://www.layui.com/&#39;</p>
<p>17 ,target: &#39;_blank&#39;</p>
<p>18 });</p>
<p>19 }</p>
<p>20 });</p>
<p>layer.msg</p>
<p>语法:layer.msg(content[, options][, end]) 提示框</p>
<p>layer.msg(&#39;这里是msg内容&#39;);</p>
<p>layer.msg(&#39;这里是msg内容&#39;,{icon:1});</p>
<p>layer.msg(&#39;关闭后想做些什么&#39;, function(){<!-- --></p>
<p>//do something</p>
<p>});</p>
<p>layer.msg(&#39;同上&#39;, {<!-- --></p>
<p>icon:1,</p>
<p>time:2000 //2秒关闭(如果不配置,默认是3秒)</p>
<p>},function(){<!-- --></p>
<p>//do something</p>
<p>});</p>
<p>layer.alert</p>
<p>语法:layer.alert(content[, options][, yes]) 普通信息框</p>
<p>//eg1</p>
<p>layer.alert(&#39;只想简单的提示&#39;);</p>
<p>//eg2</p>
<p>layer.alert(&#39;加了个图
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP