layer.js中load()方法的使用

1、load方法提供三种风格供选择。

方法一:loadIndex = layer.load(); //不传参,默认0

方法二:loadIndex = layer.load(1); // 1,另外一种风格

方法三:loadIndex = layer.load(2,{time:10*1000}); //2,换一种风格;time设置最长等待时间

load默认不会关闭,需要在complete回调中关闭。

2、项目中调取接口时,如果等待时间过长,则需要设置

$(function () {
   
var loadIndex = '';
   
$.myAjax ({
       
url: url,
       
type: "GET",
       
headers: {'Content-Type': 'application/json'},
       
beforeSend: function () {
           
loadIndex = layer.load(1, {
               
shade: [0.1, '#fff']
            });
        },
       
complete: function () {
           
layer.close(loadIndex);
        },
       
success: function (res) {},
       
error: function (e) {}
    });
});

 

猜你喜欢

转载自blog.csdn.net/g229191727/article/details/85163309