layui references js stepped pit

Preface:

Today, because the project needs, need to use layui, because of their own little front-end experience, that layui usage and other front-end framework, such as jquery, bootstrap and so on, you only need to introduce direct layui.js, and can be used directly layui.css , but when I use, has been able to find that I use the module, because the problem is to toss the afternoon, finally found the cause, hereby record

 

 

This question appears reasons, mainly because there is no document from scratch, see, a time came into contact with, go directly to the Baidu search usage, but a variety of blog elsewhere or something, just tell you this step introduction layui.js and layui.css If you only download these two files referenced down, then does not work, we take a look at the beginning of the document describes layui

 

 

 Introduction can be seen from the beginning layui and complete directory structure layui is the case, look at the following sentence,

 

 The original, layui when you're using a module, when you lay down modules in use layui.use, layui will go in your directory structure to find the module that you reference. If you only introduces layui.js this file, he can not find this directory, can not find this module. You want to use the functions do not take effect, said the official documentation for layui, in fact, mean that you should download the complete catalog layui, under this precondition, reintroduction layui.js, this time you just do not have control other files, can be used directly, for example, using methods such,

1 layui.use(['layer', 'form'], function(){
2   var layer = layui.layer
3   ,form = layui.form;
4   
5   layer.msg('Hello World');
6 });

layui.use代码你使用的哪个模块,然后layui会帮你去加载你使用的这个模块当然,还有一种其他的方法,就是引入layui.all.js 这个文件。这样就可以不用引入layui的完整目录,

 

 就像官方文档所说的,一次性全部加载,但是这样的语法和之前就不一样了。所以会变动比较大。如果你用的是layui.all.js但是却又在用layui.use这样的语法,当然是行不通的,反之亦然。

 

遇到此坑,特此记录

Guess you like

Origin www.cnblogs.com/blackmlik/p/12003966.html