在layui.use 中自定义 function 的正确方法
2019-12-25 12:03
1601 查看
适用于:
obj.click()
行内 onclick
javascript:函数名()
示例代码:
<html> <head> <link rel="stylesheet" href="layui/css/layui.css" rel="external nofollow" media="all"> </head> <body> <a class="layui-btn" id="test" href="javascript:;" rel="external nofollow" rel="external nofollow" >测试</a><br/><br/> <a class="layui-btn" onclick="hello('this is a test')" href="javascript:;" rel="external nofollow" rel="external nofollow" >hello</a> <script src="layui/layui.js"></script> <script type="text/javascript"> layui.use(["jquery","layer","form"],function(){ var $ = layui.$,layer = layui.layer,form = layui.form; $("#test").click(function(){ hello("张三"); }); window.hello = function(obj) { layer.msg("hello world,"+obj); } }); </script> </body> </html>
测试:
(1)点击测试按钮
(2)点击 hello 按钮
以上这篇在layui.use 中自定义 function 的正确方法就是小编分享给大家的全部内容了,希望能给大家一个参考
您可能感兴趣的文章:
相关文章推荐
- LA 2965 (map的正确使用方法+MEET IN THE MIDDLE)
- vc中使用SendMessage正确发送自定义消息的方法
- vc中使用SendMessage正确发送自定义消息的方法
- echarts自定义构建文件时报TypeError: uglifyPlugin is not a function错误时的解决方法
- dedecms自定义模型提示:Call to a member function GetInnerText()的解决方法
- Can’t use function return value in write context解决方法
- Android UI 之居中绘制文本内容的正确方法——实现自定义一个TextView
- vc中使用SendMessage正确发送自定义消息的方法
- 对自定义函数建立索引时抛异常--ORA-30553: 函数不能确定(ORA-30553: The function is not deterministic)解决方法
- 使用vue.use(##)构建全局方法,用this.$##使用,同时给自定义的方法 传递component调用其方法 //eventHub
- Android UI 之居中绘制文本内容的正确方法——实现自定义一个TextView
- 前端ui框架layui——layer弹出层-弹出框方法
- v-for中取子组件的ref并调用其方法的正确姿势,避免方法出现 is not a function,或者是undefined
- simulink 自定义函数S-function的字符串传递方法
- jQuery function的正确书写方法
- 前端ui框架layui——layer弹出层-内置方法
- error C4996: 'fopen': This function or variable may be unsafe. use _CRT_SECURE_NO_WARNINGS错误的解决方法
- IIS里自定义404错误页面的正确设置方法
- js通过为function设置自定义属性的方法解决闭包陷阱
- 在layui tab控件中载入外部html页面的方法