未捕获的TypeError:无法重新定义属性:nativeReduce

问题描述 投票:0回答:1

我有一个带有turbolinks的Rails应用程序。刷新页面时出现此错误

未捕获的TypeError:无法重新定义属性:来自visit.js的Function.defineProperty()的nativeReduce:1(匿名)@ visitor.js:1

在head标签中我有这个代码:

    :coffeescript
  ready = ->
    fc_CSS = document.createElement('link')
    fc_CSS.setAttribute 'rel', 'stylesheet'
    fc_isSecured = window.location and window.location.protocol == 'https:'
    fc_lang = document.getElementsByTagName('html')[0].getAttribute('lang')
    fc_rtlLanguages = [
      'ar'
      'he'
    ]
    fc_rtlSuffix = if fc_rtlLanguages.indexOf(fc_lang) >= 0 then '-rtl' else ''
    fc_CSS.setAttribute 'type', 'text/css'

    // freshdesk widget generated code


  $(document).ready(ready)
  $(document).on('turbolinks:load', ready)

每次都执行就绪功能,但发生了错误。如果我删除turbolinks它正在工作,但我想保持turbolink。

我想要的是在没有刷新页面的情况下制作一个freshdesk小部件。

javascript ruby-on-rails coffeescript turbolinks
1个回答
0
投票

我并不完全确定FreshDesk的小部件是如何工作的,但对于大多数这样的事情(Google Analytics等),您通常需要在呈现之前销毁小部件(如果存在)并重新初始化。

这里有一些好的线索:http://reed.github.io/turbolinks-compatibility/

© www.soinside.com 2019 - 2024. All rights reserved.