【发布时间】:2020-09-05 14:43:45
【问题描述】:
这是我的代码,我收到错误“ERROR TypeError: Cannot read property 'extras' of null”
ngOnInit() {
const navigation = this.router.getCurrentNavigation();
const state = navigation.extras.state as {
api: string;
trace_id: string;
token_id: string;
hotel_code: string;
result_index: string;
};
this.reqObj = {
api: state.api,
trace_id: state.trace_id,
token_id: state.token_id,
hotel_code: state.hotel_code,
result_index: state.result_index
};
}
【问题讨论】:
-
您是否尝试将同一段代码移至构造函数?
-
你可以在这里找到答案:stackoverflow.com/questions/57620180/…
标签: angular