最基本的API

Posted 向阳光大道勇猛前进吧,了解但不走偏门!

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了最基本的API相关的知识,希望对你有一定的参考价值。

var api = {
	//插件参数设定
	config: function (opts) {
		if(!opts) return options;
		for(var key in opts) {
			options[key] = opts[key];
		}
		return this;
	},
	//插件监听
	listen: function listen(elem) {
		if (typeof elem === ‘string‘) {
			var elems = document.querySelectorAll(elem),
				i = elems.length;
				while (i--) {
					listen(elems[i]);
				}
				return
		}
		//插件功能函数可以写在这
		return this;
	}
}
//将API赋值给插件名字
this.pluginName = api;

  

以上是关于最基本的API的主要内容,如果未能解决你的问题,请参考以下文章