简体   繁体   English

ReactJs Antd - window.open 动态 url

[英]ReactJs Antd - window.open an url dynamically

Im using the below code to open an url on a popup window.我使用下面的代码在弹出窗口中打开一个 url。

{
        title: 'Contract',
        dataIndex: 'index',
        key: 'contract',
        render: (text,record,index) =>
            <button onClick={() => window.open({record.contract}, "Popup","width=600, height=600")}>
              Open
            </button>
      },

The issue is that i can't call the object value {record.contract} .问题是我不能调用对象值{record.contract} It throws the Unexpected token, expected "," error.它抛出Unexpected token, expected ","错误。

Can someone help?有人可以帮忙吗?

Unexpected Token errors normally happen when your the programming syntax is not correct.当您的编程语法不正确时,通常会发生意外的令牌错误。

{record.contract} is not valid syntax. {record.contract}不是有效的语法。

when passing to a method inside an event, you should use the variable name directly.当传递给事件内的方法时,您应该直接使用变量名。 the correct syntax for your button will be:您的按钮的正确语法是:

<button onClick={() => window.open(record.contract, "Popup","width=600, height=600")}>
    Open
</button>

This will solve the unexpected token error.这将解决意外的令牌错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM