pushState
里的title并没有什么卵用
(function (doc, win) {
function Router () {
this.state = {};
this.events = [];
}
//添加popstate事件
win.addEventListener('popstate', function (e) {
})
Router.prototype = {
on: function (ev, callback){
this.events.push(ev)
},
set: function (url, title, callback){
history.pushState({url: url}, title, url);
this.state[url]=1;
},
check: function (url){
return this.state.url?true:false;
},
delete: function (url){
if(this.check(url)){
delete this.state.url
}else {
return ;
}
},
setTitle: function (title) {
title === 'string' ? title = title : title = title.toString();
document.title = title
},
refresh: function () {
}
}
win.Router?win.Router:win.Router=Router;
})(document, window)