如何让模块a覆盖模块b的方法
#1826
Replies: 4 comments 1 reply
-
addons.js - layui.define([], function(exports) {
+ layui.define(['yznForm'], function(exports) {
- layui.use(['yznForm'], function(exports) {
var yznForm = layui.yznForm;
yznForm.events.bindevent= function (form) {
alert("替换成功");
}
- })
exports('addons', '');
}); yznForm.js layui.define([], function(exports) {
var addons = layui.addons;
var $ =layui.jquery;
var yznForm = {
events: {
bindevent: function () {
alert("没有被替换");
}
}
}
- yznForm.events.bindevent();
+ yznForm.init = function(){
+ yznForm.events.bindevent();
+ }
exports('yznForm', yznForm);
}); html <!-- body 末尾处引入 layui -->
<script src="layui/layui.js"></script>
<script type="text/javascript">
layui.config({
version: '1.0.2',
base: 'layui_exts/'
}).extend({
yznForm: 'yznForm',
addons: 'addons'
- }).use(['addons', 'yznForm']);
+ }).use(['addons', 'yznForm'], function(){
+ var yznForm = layui.yznForm;
+ yznForm.init()
});
</script> |
Beta Was this translation helpful? Give feedback.
0 replies
-
非常感谢大神回复
|
Beta Was this translation helpful? Give feedback.
0 replies
-
是这样的 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
定义两个模块
模块a addons.js
模块b yznForm.js
如何让模块a重写覆盖模块b的方法 也就是先弹出alert("替换成功");
Beta Was this translation helpful? Give feedback.
All reactions