我希望尝试router.js,但我很难这样做。 根据我的理解,它可以单独使用(没有ember或其他框架),所以我已下载并导入它。
<!DOCTYPE html>
<html>
<head>
<title>routerJS</title>
</head>
<body>
<script src="js/router.js"></script>
<script src="js/app-routing.js"></script>
</body>
</html>
在应用程序路由中,我只是实例化一个新的路由器
var router = new Router();
但我得到了
Uncaught TypeError:undefined不是函数router.js:144
所以我仔细检查了repo README并添加了几个依赖项:
<!DOCTYPE html>
<html>
<head>
<title>routerJS</title>
</head>
<body>
<script src="js/rsvp.js"></script>
<script src="js/route-recognizer.js"></script>
<script src="js/router.js"></script>
<script src="js/app-routing.js"></script>
</body>
</html>
现在我得到了
未捕获的SyntaxError: /js/route-recognizer.js:296
我还在这里遗漏一些东西吗? 我怎样才能成功使用route.js?
感谢。