【问题标题】:how can angular navigate to www.google.com [duplicate]角度如何导航到 www.google.com [重复]
【发布时间】:2020-08-15 23:48:14
【问题描述】:

我正在使用 Angular 7 将应用导航到 https:www.google.com,

constructor( public router: Router ) {
  this.router.navigateByUrl("https://www.google.com");
}

但它给了我错误提示

core.js:15724 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'https:'
Error: Cannot match any routes. URL Segment: 'https:'
    at ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:2469)

有什么方法可以传递它吗?

【问题讨论】:

    标签: angular


    【解决方案1】:

    您不能使用路由器服务导航到外部链接。

    您可以使用:window.location.href = 'some-url'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-05
      • 1970-01-01
      • 2015-09-19
      • 2018-06-25
      • 1970-01-01
      • 2019-01-25
      • 1970-01-01
      • 2021-03-26
      相关资源
      最近更新 更多