我在Angular 5应用程序中使用Google Picker时遇到了问题。
在选择器回调中,我隐藏了选择器,然后导航到另一个页面。但是目标页面的加载很奇怪:前一个页面的一些元素仍然在那里,新的元素部分显示。几秒钟后,或者手动重新加载页面后,一切看起来都很好。Google Picker注入的html似乎破坏了一些东西。
下面是我的选择器回调:
onPickerChosen(data: any) {
const action = data[google.picker.Response.ACTION];
if (action === google.picker.Action.CANCEL) {
this.picker.setVisible(false);
this.router.navigate(['/home'], { replaceUrl: true });
} else if (action === google.picker.Action.PICKED) {
this.picker.setVisible(false);
// ...
this.router.navigate(['/map-edit', googleFileId]);
}
}我必须处理一些东西吗?(我也尝试过使用this.picker.dispose())。有人能帮我吗?谢谢!
发布于 2018-03-20 22:59:45
我用一种不好的方式解决了这个问题,但是它起作用了:在页面改变之前强制角度刷新。
所以:
this.router.navigate(['/home'], { replaceUrl: true });变成:
this.zone.run(() => {
this.navigate(['/home'], { replaceUrl: true });
}https://stackoverflow.com/questions/49383206
复制相似问题