layui.use

最近在学layui,在学到加载模块的时候遇到了一些麻烦。
产生的疑惑,为什么提示xx.xx is not a function / type error没有这个方法

layui.use([mods, mod2], callback)
var mods = layui.form, mod2 = layui.mod2;
mods.method()

最后明白这里的意思是加载layui的指定模块。
然后调用加载的这个模块的方法。
这个模块的js文件要在layui中有,并且调用的方法得是这个js中含有的。

layui.use(['layer', 'form'], function(){
var layer = layui.layer ,form = layui.form;
layer.msg('Hello World'); // 正常运行
form.msg('Hello World'); // Uncaught TypeError: form.msg is not a function
});
posted @ 2021-03-14 15:46  张三丰学Java  阅读(4551)  评论(0编辑  收藏  举报