企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 第一步:JS ``` /** * @ Name: layui.notification 通知模块儿 * @ Author: 贤心 * @ License:MIT */ layui.define('layer', function(exports){ var $ = layui.$ ,layer = layui.layer //外部接口 ,notification = { //... //详见下篇 } //构造器 ,Class = function(options){ //... }; //默认配置 Class.prototype.config = { //…… }; //核心入口 notification.open = function(options){ return layer.msg(options); }; exports('notification',notification); }); ``` ## 第二步:使用 ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <title>开始编写一个自己的模块:notification</title> <link rel="stylesheet" href="../layui/css/layui.css"> </head> <body> <script src="../layui/layui.js" charset="utf-8"></script> <script> layui.config({base: '../mods/'}).use('notification', function(){ var $ = layui.$ ,notification = layui.notification; notification.open('hello'); }); </script> </body> </html> ```