看Vue.use方法,想起了以前工作中别人用过的use方法。

var YANMethod = {
using:function() {
var a = arguments, o = this, i = 0, j, d, arg, isExist;
arg = a[0], isExist = a[1];
if (arg && arg.indexOf('.')) {
d = arg.split('.');
for (j = (d[0] == 'YAN') ? 1 : 0; j < d.length; j++) {
if(!o[d[j]] && isExist) return null;
o[d[j]] = o[d[j]] || {};
o = o[d[j]];
}
} else {
o[arg] = o[arg] || {};
}
return o;
},
/*--
用新Cookie方法,但是兼容老的东西
-ver 2014-04-22
*/
cookie:function(name, value, options) {
if(typeof value==='undefined'){
return Cookie.get(name);
}
if(options){
options.exp = typeof options.expires==='number' ? options.expires * 24 :
options.expires; //原来的cookie是按天算的
}
Cookie.set(name, value, options);
}, /**
*JSON序列化,如果传入的是字符串则反序列化为对象;若传入的是对象则反序列化为字符串
*/
json:function(value){
if(typeof value==="string"){
return this.jsontoObject(value);
}else{
return this.jsontoJSON(value);
}
},
jsontoJSON:function(object){
var type = typeof object;
if ('object' == type) {
if (Array == object.constructor) type = 'array';
else if (RegExp == object.constructor) type = 'regexp';
else type = 'object';
}
switch (type) {
case 'undefined':
case 'unknown':
return;
break;
case 'function':
case 'boolean':
case 'regexp':
return object.toString();
break;
case 'number':
return isFinite(object) ? object.toString() : 'null';
break;
case 'string':
return '"' + object.replace(/(\\|\")/g, "\\$1").replace(/\n|\r|\t/g, function() {
var a = arguments[0];
return (a == '\n') ? '\\n': (a == '\r') ? '\\r': (a == '\t') ? '\\t': ""
}) + '"';
break;
case 'object':
if (object === null)
return 'null';
var results = [];
for (var property in object) {
var value = this.jsontoJSON(object[property]);
if (value !== undefined)
results.push(this.jsontoJSON(property) + ':' + value);
}
return '{' + results.join(',') + '}';
break;
case 'array':
var results = [];
for (var i = 0; i < object.length; i++) {
var value = this.jsontoJSON(object[i]);
if (value !== undefined)
results.push(value);
}
return '[' + results.join(',') + ']';
break;
}
}, jsontoObject:function(strjson){
return eval("(" + strjson + ")");
}
};
var addFunToYAN = function(functionName,func){
if(typeof(func) == 'function')
YAN[functionName] = func;
};
for(var m in YANMethod){
if(typeof(YAN[m]) == 'undefined'){
addFunToYAN(m,YANMethod[m]);
}
}
$.extend(YAN.using("Plugin"),{ });
$.extend(YAN.using("Utils"),{
getQuery:function(name){
var paramList = location.search.replace("?","").split("&");
for(var i = 0 ; i < paramList.length ; i++)
{
if(paramList[i].split("=")[0] == name){
return paramList[i].substring(paramList[i].indexOf("=") + 1,paramList[i].length);
}
}
return null;
}
});
var Plugin = YAN.using('Plugin'); Plugin.AD = ad;
Plugin.AD.getFlashAd(); window.AD || (window.AD = YAN.using('Plugin').AD);

Vue.use()

http://www.cnblogs.com/dupd/p/6716386.html

最新文章

  1. ionic build Android错误记录未解决
  2. 常用CSS缩写语法总结
  3. Leetcode Search for a Range
  4. python 培训之 装饰器
  5. Union函数
  6. JavaScript实现http地址自动检测并添加URL链接
  7. jq使用手册
  8. Razor视图引擎布局
  9. opensuse安装mysql-workbench
  10. Ultra-QuickSort(树状数组+离散化)
  11. oracle丢失temp表空间处理
  12. Null指针
  13. ubuntu oracle jdk
  14. ofBiz-groovy-freemarker
  15. git关联了无用的,取消关联,并重置gitignore
  16. centos 7 安装iptables防火墙
  17. &lt;asp:Button点击查询后,调用js中函数展现加载圈
  18. SQL Server 查询表的字段对应描述、数据类型、长度
  19. iOS记录一常用的方法和语句
  20. fuzz for test of the Net::HTTP::GET

热门文章

  1. Linux UinxODBC安装与配置
  2. Angular routing生成路由和路由的跳转
  3. Fedora 安装Docker
  4. Provinces of China
  5. Android Java层,Native层,Lib层打印Log简介【转】
  6. vim使用跳转列表 jumps 来跟踪 (历史位置的)导航
  7. luogu1975 [国家集训队]排队
  8. P2596 [ZJOI2006]书架
  9. IntelliJ IDEA 中SpringBoot对Run/Debug Configurations配置 SpringBoot热部署
  10. How do I extract a single column from a data.frame as a data.frame