NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
[TOC] > [参考](https://layui.itze.cn/doc/base/modules.html) ## 概述 ``` common ├── common.js └── module └── global.js ``` global.js 文件定义全局信息 ``` //提示:模块也可以依赖其它模块,如:layui.define('mod1', callback); layui.define(function(exports){ var obj = { admin_path: "/adminx/", }; //输出 mymod 接口 exports('global', obj); }); ``` common.js ``` var root_path = (function (src) { src = document.currentScript ? document.currentScript.src : document.scripts[document.scripts.length - 1].src; return src.substring(0, src.lastIndexOf("/") + 1); })(); root_path="{/}"+root_path+"/module/" layui.extend({ global: root_path+'global' // {/}的意思即代表采用自有路径,即不跟随 base 路径 }) ```