ITPub博客

首页 > 应用开发 > > 请帮忙修正插件函数错误之处,非常感谢!

请帮忙修正插件函数错误之处,非常感谢!

作者:hawkliu 时间:2019-08-15 09:29:49 0 删除 编辑
;(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/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-07-29

  • 博文量
    274
  • 访问量
    1130