具有8080端口的window.location无法重定向到另一个位置

时间:2019-02-08 10:45:31

标签: html reactjs

我在服务器的8080端口上运行了ReactJS应用程序。

在某个屏幕上,我得到以下窗口位置:

console.log(window.location)

ancestorOrigins: DOMStringList {length: 0}
assign: ƒ ()
hash: ""
host: "170.80.224.142:8000"
hostname: "170.80.224.142"
href: "http://170.80.224.142:8000/"
origin: "http://170.80.224.142:8000"
pathname: "/"
port: "8000"
protocol: "http:"
reload: ƒ reload()
replace: ƒ ()
search: ""
toString: ƒ toString()
valueOf: ƒ valueOf()
Symbol(Symbol.toPrimitive): undefined
__proto__: Location

此页面包含以下组件:

class NavButton extends Component {
    handleModuleNav = action => {
        let to = "/" + action;
        window.location = to;
    };

    render = () => {
        return (
          <div onClick={() => this.handleModuleNav("admin")}>
             GO TO ADMIN
          </div>
        )
    }
}

单击按钮时,我的应用将转到“ http://170.80.224.142/admin”,缺少8080端口。

如何确保已添加端口? (IP地址和端口可能会有所不同,我需要确保将使用加载的IP和PORT。)

0 个答案:

没有答案
相关问题