对讲机必须双击才能出现菜单。

时间:2018-11-30 15:42:09

标签: reactjs typescript intercom

我必须双击我的支持按钮,以使对讲机消息出现在初次点击时

    private handleSupportClick() {
        const ic = (window as any).Intercom;
        function l() {
            const d = document;
            const s = d.createElement('script');
            s.type = 'text/javascript';
            s.async = true;
            s.src = 'https://widget.intercom.io/widget/';
            const x = d.getElementsByTagName('script')[0];
            (x as any).parentNode.insertBefore(s, x);
        }
        (window as any).intercomSettings = {
            app_id: process.env.REACT_APP_INTERCOM_APP_ID as string,
            hide_default_launcher: true
        };
        (() => {
            l();
            if (typeof ic === "function") {
                ic('reattach_activator');
                ic('show', (window as any).intercomSettings);
            } else {
                const i = (...args: any) => {
                    (i as any).c(...args)
                };
                (i as any).q = [];
                (i as any).c = (args: any) => {
                    (i as any).q.push(args)
                };
                (window as any).Intercom = i;
                this.handleSupportClick();
            }
        })()
    }

不过,在首次点击后,只需点击一次我的支持按钮即可召唤同一个Messenger。我逐字逐句地跟踪了调试器中的流程,但是我仍然找不到为什么这需要双击。当然,我已经使该函数在初次单击后再次调用了它自己,但是这仍然无法正常工作,并且我收到一条错误消息,提示“在非对象上调用了CreateListFromArrayLike”

任何帮助都将不胜感激。

0 个答案:

没有答案