피라미드에서 제공되는 ember.js를 사용하여 SPA (단일 페이지 응용 프로그램)를 개발 중입니다. 문제는 라우팅이 제대로 작동하지 않는다는 것입니다.피라미드 및 ember.js를 사용하여 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
보기는 다음과 같습니다 : 피라미드에서
는, 나는 다음과 같은 노선 정의
다음@view_config(route_name='index')
def index_view(request):
with open('myapp/templates/index.html', 'rt', encoding='utf-8') as fh:
html = fh.read()
return Response(html, content_type='text/html')
내 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
는 : "안녕하세요, 세계"나는 localhost:6543/
에 갈 때
Wfw.Router.map(function() {
this.resource('wfw', { path: '/t' });
});
내가 얻을 수 있지만, 나는 "여기에 페이지입니다"표시되지 않습니다. 의 js/router.js
을 '/test'
으로 변경하고 localhost:6543/test
으로 이동하면 404가됩니다. 무엇이 잘못 되었나요? 피라미드의 경로를 일부 사용하지 않도록 설정해야합니까? 아니면 엠버에게 문제가 있습니까?
감사합니다 : 귀하의 URL이처럼 될 필요가 있으므로
기본적으로, 엠버는 HTML5의 역사 API를 사용하지 않습니다. '/ t '는 문제의 오타 였지만, 그 문제는 실종 된'#'이었습니다. 내가 완벽하게 작동한다고 덧붙였다. – aquavitae