@tisha077

Как настроить route в CanJS чтобы ссылки были без #?

Как настроить route в CanJS чтобы ссылки были без #!?
Сейчас: example.com/#!/firstPage
Надо: example.com/firstPage
В AngularJS используется $locationProvider.html5Mode(true);
В EmberJS используется App.Router.reopen({ location: 'auto' });
Не могу найти похожей функциональности для CanJS...
  • Вопрос задан
  • 2310 просмотров
Решения вопроса 1
mlnkv
@mlnkv
JavaScript Developer
Мне кажется, там нет такого
кусок кода из route.js
...
bindings: {
	hashchange: {
		paramsMatcher: paramsMatcher,
		querySeparator: "&",
		// don't greedily match slashes in routing rules
		matchSlashes: false,
		bind: function () {
			can.bind.call(window, 'hashchange', setState);
		},
		unbind: function () {
			can.unbind.call(window, 'hashchange', setState);
		},
		// Gets the part of the url we are determinging the route from.
		// For hashbased routing, it's everything after the #, for
		// pushState it's configurable
		matchingPartOfURL: function () {
			return location.href.split(/#!?/)[1] || "";
		},
		// gets called with the serialized can.route data after a route has changed
		// returns what the url has been updated to (for matching purposes)
		setURL: function (path) {
			location.hash = "#!" + path;
			return path;
		},
		root: "#!"
	}
},
...


нет намека на условие, типа использовать восклицательный знак или нет,
P.S. можно самому добавить)
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы