FB.ui弹出块在chrome javascript反应

时间:2018-01-17 06:38:18

标签: javascript reactjs popup

我在FB.ui中遇到麻烦,因为它被Chrome阻止了。我正在使用反应javascript。我尝试搜索,但找不到一个。 有什么建议吗?

以下是我的代码:

<button onClick={this.firstFunction}>Click Here</button>

firstFunction = (e) => {
    const { actions } = this.props;

    if (login.isLoggedIn) {
        actions.saveFirst();
    } else {
        toast.error("You need to login to share");
    }

    setTimeout(() => this.secondFunction(e), 5000);

}

secondFunction() => {
  FB.ui({
        method: "share_open_graph",
        action_type: "og.shares",
        action_properties: JSON.stringify({
            object : {
                "og:url": 
               `${window.location.href}`,
                "og:title": name,
                "og:description": description,
                "og:image": image,
            }
        })
    }, (response) => {
        if (response && !response.error_code) {
            // console.log("Posting completed.");
        } else {
            // console.log("Error");
        }
    }); 
}

0 个答案:

没有答案