首页 > 应用开发 > > 请帮忙修正插件函数错误之处,非常感谢!
;(function() {
"user strict";
//默认参数
var size = {
var options = {
color: 'red'
};
}
//插件函数color
var color = {
//更新配置参数
var config: function(opts) {
if(!opts) return options;
for (var k in opts) {
options[k] = opts[k];
}
return this;
},
//监听事件
var listen: function(elem) {
var elems = document.getElementById('elem');
elems.addEventListener('click',function() {
this.style.color = options.color;
})
}
return this;
}
window.Color = color;
})()
//对象链式调用:
//Color.config({color: 'red'}).listen('#sz');来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/887/viewspace-3168310/ ,如需转载,请注明出处,否则将追究法律责任。