如何安装独立的ember路由器?

时间:2014-07-02 13:21:32

标签: javascript asp.net-mvc ember-router

我在安装时遇到问题 - >我的MVC项目中https://github.com/tildeio/router.js

我首先加载了这两个脚本:

vendor/deps/route-recognizer.js
dist/router.js

添加了一行:

var router = new Router();

我最终遇到了以下控制台错误:

Uncaught ReferenceError: define is not defined ***route-recognizer.js:1***
Uncaught TypeError: Cannot read property 'Promise' of undefined ***router.js:2084***
Uncaught ReferenceError: Router is not defined 

然后我加载了这些脚本:

vendor/loader.js
vendor/deps/backburner.js
vendor/deps/rsvp.js
vendor/deps/route-recognizer.js
dist/router.js

我收到这些错误:

Uncaught TypeError: Cannot read property 'Promise' of undefined ***router.js:2084***
Uncaught ReferenceError: Router is not defined 

这是承诺'承诺'发生错误:

   define("route-recognizer", [], function() { return {"default": RouteRecognizer}; });
   define("rsvp", [], function() { return RSVP;});
-->define("rsvp/promise", [], function() { return {"default": RSVP.Promise}; });

我还需要一个promise.js吗?我在RSVP.js包中找到了promise.js,但是加载给了我另一个错误。

1 个答案:

答案 0 :(得分:1)

遇到了同样的问题。

根据this postrouter.js的代码更改似乎是独立的。

抓住后者rsvproute-recognizerrouter并创建一个像这样的路由器对象

<script src="routerjs/rsvp-latest.js"></script>
<script src="routerjs/route-recognizer.js"></script>
<script src="routerjs/router.min.js"></script>
<script>
  var router = new Router["default"]();
</script>