用金字塔和余烬

2024-06-14 12:09:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在开发一个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视图是:

^{pr2}$

这是我的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',然后转到{},我得到404。我做错什么了?我是否需要以某种方式禁用金字塔的路由,或我做了什么错误的余烬?在


Tags: srccom路由indexhtmljsscriptbootstrap
1条回答
网友
1楼 · 发布于 2024-06-14 12:09:40

几件事:

  1. 我想你需要把你的余烬在应用程序特定标记上方编写标记脚本。

  2. 您配置的路径是/t,所以我认为它不会选择/test

  3. 默认情况下,ember不使用html5历史api,因此您的url需要如下所示:localhost:6543/#/t

相关问题 更多 >