我正在开发一个SPA(单页应用程序)使用余烬从金字塔服务。问题是路由不能正常工作。在
在金字塔中,我定义了以下路径:
# Route to index.html, i.e. the SPA
config.add_route('index', '/')
# Route to css & js resources
config.add_static_view('', 'myapp:static')
而index
视图是:
这是我的index.html
:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="libs/bootstrap/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<h1>Hello, world!</h1>
<script type="text/x-handlebars" data-template-name="wfw">
<section id="wfw">
<p>here is a page</p>
</section>
</script>
<script src="js/application.js"></script>
<script src="js/router.js"></script>
<script src="https://code.jquery.com/jquery.js"></script>
<script src="http://builds.emberjs.com/release/ember.js"></script>
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
<script src="https://raw.github.com/less/less.js/master/dist/less-1.6.0.min.js"></script>
<script src="libs/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
js/application.js
:
window.Wfw = Ember.Application.create();
js/router.js
:
Wfw.Router.map(function () {
this.resource('wfw', { path: '/t' });
});
当我去localhost:6543/
我得到“你好,世界!”,但我没有看到“这是一页”。如果我把js/router.js
中的path
改为'/test'
,然后转到{
几件事:
我想你需要把你的余烬在应用程序特定标记上方编写标记脚本。
您配置的路径是
/t
,所以我认为它不会选择/test
。默认情况下,ember不使用html5历史api,因此您的url需要如下所示:
localhost:6543/#/t
相关问题 更多 >
编程相关推荐