我正在尝试一种非常简单的路由,却无法使其正常工作。我的代码:
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<dom-module id="lab1-app">
<template>
<style>
:host {
display: block;
}
</style>
<app-location route="{{rt}}"></app-location>
<app-route
route="{{rt}}"
pattern="/:view"
data="{{rd}}"
tail="{{tail}}"
></app-route>
<iron-pages selected="[[rd.view]]" attr-for-selected="pgid" fallback-selection="404" >
<h2 pgid="profile">Profile</h2>
<h2 pgid="detail">Detail</h2>
<h2 pgid="form">Form</h2>
<h2 pgid="404">404</h2>
</iron-pages>
</template>
<script>
/**
* @customElement
* @polymer
*/
class Lab1App extends Polymer.Element {
static get is() { return 'lab1-app'; }
static get properties() {
// console.log(dataRute);
return {};
}
}
window.customElements.define(Lab1App.is, Lab1App);
</script>
</dom-module>
我不确定哪个部分出错了,我可以告诉铁页工作,因为它总是显示404,
但是当我尝试加载localhost:8081/detail
时,它仍会显示404.任何帮助都表示赞赏。谢谢!
答案 0 :(得分:0)
实施没有错,我忘记在index.html中导入<app-location>
<link rel="import" href="../../bower_components/app-route/app-location.html">
是的,愚蠢的错误。抱歉用于获取磁盘空间的stackoverflow