cyra
Version:
single page application view engine
35 lines (34 loc) • 909 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var util_1 = require("../../util");
var HashPath = (function () {
function HashPath(obj) {
this.routing = obj.routing;
}
/**
* 开始路由
*/
HashPath.prototype.start = function () {
var _this = this;
window.addEventListener('hashchange', function (e) {
_this.routing(_this.getParams);
});
this.routing(this.getParams);
};
/**
* 更新 URL
* @param {UrlObject} urlObject
*/
HashPath.prototype.updatePath = function (urlObject, isShadow) {
util_1.setHashData(urlObject, isShadow);
};
/**
* 从 URL 上获取 Path 和参数
* @return {UrlObject}
*/
HashPath.prototype.getParams = function () {
return util_1.getHashData();
};
return HashPath;
}());
exports.default = HashPath;