お世話になります。
Riot Routerで、意図的に、route(To)メソッドだと、URLの変更を検知できるのですが、
ブラウザ進む/戻るボタンでのURLの変更を検知できないのです
進む/戻るボタンのURL変更の検知ができる方法を知っておられる方、教えて頂けると助かります。
また、route(To)メソッドだとURLに必ず#がついてしまうのですが、#が付かない方法って別にあるのでしょうか。
以下は、Riot RouterのURL変更検知のサンプルソースです。
html
1<!DOCTYPE html> 2<html> 3<head> 4<title>riot router sample</title> 5<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 6<script src="https://cdn.jsdelivr.net/npm/riot-route@3.1.1/dist/route.min.js"></script> 7</head> 8<body> 9<button id="button1">あ</button> 10<button id="button2">い</button> 11<button id="button3">う</button> 12<button id="button4">え</button> 13<script> 14 route(function(num) { 15 console.log(num) 16 }) 17 $('#button1').click(function(){ 18 route("1") 19 }); 20 $('#button2').click(function(){ 21 route("2") 22 }); 23 $('#button3').click(function(){ 24 route("route/3") 25 }); 26 $('#button4').click(function(){ 27 route("hoge/4") 28 }); 29</script> 30</body> 31</html>
あなたの回答
tips
プレビュー