我已经开始使用离子3(from django.conf.urls import url
from.import views
# app_name not appname
app_name= 'accounts'
urlpatterns = [
url(r'^signup/$', views.signup_view, name= "signup"),
url(r'^login/$', views.login_view, name = "login" ),
]
)并收到此错误。我检查了这个link以及其他许多内容,但在我的案例中没有一个是有用的。
错误错误:未捕获(承诺):无效链接:LoginPage
"@ionic/app-scripts": "3.1.6"
:
app.component.ts
const unsubscribe = firebase.auth().onAuthStateChanged( user => {
if (!user) {
this.rootPage = 'LoginPage';
unsubscribe();
} else {
this.rootPage = HomePage;
unsubscribe();
}
});
:
login.ts
最初有效,但现在它无法工作并显示相同的错误。 如果我遗漏了任何其他配置,请告诉我。
编辑:@IonicPage({
name: 'login'
})
@Component({
selector: 'page-login',
templateUrl: 'login.html'
})
export class LoginPage {
// ......
}
:
package.json
答案 0 :(得分:4)
您正在使用延迟加载,但您也在更改页面名称:
@IonicPage({
name: 'login' // <---- here!
})
@Component({
selector: 'page-login',
templateUrl: 'login.html'
})
export class LoginPage {
// ......
}
正如您在 the IonicPage docs 中看到的那样:
如前所述,name属性将设置为该类 如果没有提供名称。更改链接的名称非常重要 简单。要更改用于链接到组件的名称,只需传递即可 它在装饰器中就像这样:
@IonicPage({ name: 'my-page' })
这将使用名称创建指向MyPage组件的链接 '我的页面'。与前面的示例类似,可以导航页面 通过使用名称:
goToMyPage() { // go to the MyPage component this.navCtrl.push('my-page'); }
因此,如果您在name
装饰器中选择@IonicPage
'登录',请在尝试使用该页面时使用相同的名称:this.rootPage = 'login';
答案 1 :(得分:1)
您似乎正在使用Angularfire2
。所以你可以很容易地这样做,
app.component.ts
import { AngularFireAuth } from 'angularfire2/auth';
constructor(private afAuth: AngularFireAuth) {
this.afAuth.authState.subscribe(user => {
if (user) {
this.rootPage = 'HomePage';
} else {
this.rootPage = 'LoginPage';
}
});
}