layui custom modules and references

1, define the module
layui.define('jquery', function(exports){
var $ = layui.jquery
var base =
test:function(){
console.log("helloworld")
}
}
exports('base', base);
});
2. Reference modules
layui.config({
version: true //Generally used to update the module cache, it is not enabled by default. Set to true to prevent the browser from caching. It can also be set to a fixed value, such as: 201610
,debug: false //Used to enable debugging mode, the default is false, if set to true, the node of the JS module will remain on the page
,base: 'static/adminjs/' //Set the directory where the extended Layui module is located, generally used for external module expansion
}).use(['base'],function(){
var base = layui.base
base.test()
})

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325708997&siteId=291194637