How to use Layui
This article mainly introduces how to use Layui, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Layui (homophonic: class UI) is a front-end UI framework written by its own module specification, which follows the writing and organization form of native HTML/CSS/JS. It has a very low threshold and is ready to use. Very suitable for the rapid development of the interface.
After you get the layui and deploy it completely to your project directory (or static resource server), you only need to introduce the following two files:
. / layui/css/layui.css./layui/layui.js / / Tip: if it is in a non-modular way (explained at the bottom), it can be replaced here with:. / layui/layui.all.js
That's right, you don't have to worry about any other files. Because they (such as modules) are only loaded automatically when they are finally used.
This is a basic getting started page:
Start using layui / / generally write layui.use directly in a js file (['layer',' form'], function () {var layer = layui.layer, form = layui.form; layer.msg ('Hello World');})
Note: to use layui, you need to load the module first, and the module is preloaded in the above code! If you do not load the module at first, you will directly layer. If you use it, the runtime will report an error! Other problems such as layer cannot be found or the method cannot be found!
Layui.use (['layer',' form'], function () {var layer = layui.layer, form = layui.form;})
Here is a code example I used:
Call layui:
Preload:
/ / layui layerlet layuiLayer;//layui preloads layui.use (['layer'], function () {layuiLayer = layui.layer;})
Use the layui object:
LayuiLayer.open ({title: 'prompt', content: 'please enter a name!' }) Thank you for reading this article carefully. I hope the article "how to use Layui" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!