1.0.2 • Published 7 years ago

arouters v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

arouters

一个简单的路由,用于ajax为主的单页面应用

方法

  • getParamsUrl: 获取页面对应的hash

  • routers: object - 存储每个单页对应的操作

  • register: 用于页面注册 - path: string - 对应的hash - file: object - 需要插入的js和css路径

  • init: 绑定loadhashchange事件

  • refresh: 刷新页面

  • execute: 插入文件,执行业务逻辑

  • enter: js文件加载后,业务逻辑执行入口

  • leave: 离开一个单页时需要做的操作,比如手动管理内存

  • beforeFunafterFun: 用于横向业务逻辑,使用者可以根据自己需要自由放置位置

例子

初始化:

	spaR.register("index1",{
		js: "index1.js",
		css:"index1.css"
	});
	spaR.register("index2",{
		js: "index2.js",
		css:"index2.css"
	});
	spaR.register("index3",{
		js: "index3.js",
		css:"index3.css"
	});

业务代码:

var timer1 = null;

spaR.enter(function(){
	console.info("enter1");
	timer1 = setTimeout(function(){
		console.info("timer1");
	},5000);
});

spaR.leave(function(){
	console.info("leave1");
	clearTimeout(timer1);
});

详见example.

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago