【问题标题】:ReactJs Antd - window.open an url dynamicallyReactJs Antd - 动态打开一个 url
【发布时间】:2021-07-21 21:31:08
【问题描述】:

我使用下面的代码在弹出窗口上打开一个 url。

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

问题是我不能调用对象值{record.contract}。 它会抛出 Unexpected token, expected "," 错误。

有人可以帮忙吗?

【问题讨论】:

    标签: reactjs antd


    【解决方案1】:

    当您的编程语法不正确时,通常会发生意外的 Token 错误。

    {record.contract} 的语法无效。

    在事件内部传递给方法时,应直接使用变量名。 您的按钮的正确语法是:

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

    这将解决意外的令牌错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-15
      • 2019-11-18
      • 1970-01-01
      • 2019-09-03
      • 2023-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多