Home >Web Front-end >Layui Tutorial >How to use jquery in layui

How to use jquery in layui

藏色散人
藏色散人Original
2021-01-19 09:36:568972browse

How to use jquery in layui: 1. Use it through "layui.use('jquery', function(){var $=layui.$...}"; 2. Use it through "layui.use( ['form','layer']..." method is used.

How to use jquery in layui

The operating environment of this tutorial: Windows 7 system, layui version 2.5.6, Dell G3 computer .

Recommended: "layUI Tutorial"

layui is a framework based on jQuery, and it comes with jQuery, so how does layui use the internal jquery?

Here’s a note on how to use jQuery internally:

layui.use('jquery', function(){ 
  var $ = layui.$ //重点处
  
  //后面就跟你平时使用jQuery一样
  
});

Another one:

//如果内置的模块本身是依赖jquery,你无需去use jquery,所以上面的写法其实可以是:
layui.use(['form','layer'],function () {
            var $ = layui.$;
            var form = layui.form;
            var layer = layui.layer;
            }

Generally, just use the latter one

The above is the detailed content of How to use jquery in layui. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to quote layuiNext article:How to quote layui