Layer Mobile 代码示例

140次阅读
没有评论

Layer Mobile 代码示例

layer PC 端和移动端在 ui 和操作习惯上还是有很大区别的,面向移动端使用 PC 端的 layer 操作起来总是别扭的很,PC 版 layer 文档蛮多的,但是 Mobile 版的文档 demo 着实不好找。

 

下载:https://github.com/layui/layer/releases/tag/v3.5.1

代码 +DEMO 文档下载: 蓝奏盘

演示示例:Layer Mobile

使用 Mobile 版弹层

<script src="./layer-v3.5.1/layer/mobile/layer.js" ></script>
/** 以下是小试牛刀的调用代码(此处不展示事件绑定)*/

  // 信息框
  layer.open({
    content: '移动版和 PC 版不能同时存在同一页面'
    ,btn: '我知道了'
  });

  // 提示
  layer.open({
    content: 'hello layer'
    ,skin: 'msg'
    ,time: 2 // 2 秒后自动关闭
  });

  // 询问框
  layer.open({
    content: '您确定要刷新一下本页面吗?'
    ,btn: ['刷新', '不要']
    ,yes: function(index){location.reload();
      layer.close(index);
    }
  });

  // 底部对话框
  layer.open({
    content: '这是一个底部弹出的询问提示'
    ,btn: ['删除', '取消']
    ,skin: 'footer'
    ,yes: function(index){layer.open({content: '执行删除操作'})
    }
  });

  // 底部提示
  layer.open({
    content: '一个没有任何按钮的底部提示'
    ,skin: 'footer'
  });

  // 自定义标题风格
  layer.open({
    title: [
      '我是标题',
      'background-color: #FF4351; color:#fff;'
    ]
    ,content: '标题风格任你定义。'
  });

  // 页面层
  layer.open({
    type: 1
    ,content: '可传入任何内容,支持 html。一般用于手机页面中'
    ,anim: 'up'
    ,style: 'position:fixed; bottom:0; left:0; width: 100%; height: 200px; padding:10px 0; border:none;'
  });

  //loading 层
  layer.open({type: 2});

  //loading 带文字
  layer.open({
    type: 2
    ,content: '加载中'
  });
正文完
有偿技术支持加微信
post-qrcode
 0
评论(没有评论)
验证码