重定向外部URLAngular

我正在尝试重定向到外部 URL,我正在 localhost 上开发,所以我得到了 localhost:4200/www.example.com,我该如何解决这个问题?提前致谢

import { Component, OnInit } from '@angular/core';

@Component({
    selector: 'app-main',
    templateUrl: './main.component.html'
})

export class MainComponent implements OnInit {
    public title: string;

    constructor(){}

    ngOnInit(){
        window.location.href = 'www.example.com'
    }
}

回答

你错过了http

window.location.href = 'http://www.example.com'


以上是重定向外部URLAngular的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>