如何修复 GTM 中的 "This language feature is only supported for ECMASCRIPT6 mode"?

How to fix "This language feature is only supported for ECMASCRIPT6 mode" in GTM?

我尝试在GTM中使用一些js代码,但是出现了这个错误。 此行发生错误

window.sbHooks.addAction('sbCoreState::CreateBets/success', (data, response) => {

我在哪里使用自定义 vue js 挂钩。 我该如何解决?

<script>
if (typeof window.sbHooks === 'object') {
  // отправим данные о достижении цели (размещение ставки/прогноза) в Яндекс Метрику
  window.sbHooks.addAction('sbCoreState::CreateBets/success', (data, response) => {
    //data.express_bet - сумма экспресса, если это значение есть  - то ставка экспресс
    //data.express_tip - текст экспресса
    //добавлен экспресс с прогнозом или без
    if (
      typeof data.express_bet !== 'undefined' &&
      typeof response.body.ids !== 'undefined' &&
      Array.isArray(response.body.ids) &&
      response.body.ids.length > 0
    ) {
      if (typeof yaCounter47035968 != 'undefined') {
        yaCounter47035968.reachGoal('AddTipExpress');
        if (data.express_tip.length > 0) {
          yaCounter47035968.reachGoal('AddReviews');
        }
      }
    }

    // Если это несколько ставок, то переберем их и посмотрим есть ли текст
    if (
      typeof data.express_bet == 'undefined' &&
      data.bets.length > 0
    ) {
      for (var i = 0; i <= data.bets.length - 1; i++) {
        var tip_text = data.bets[i].tip_text;
        if (typeof yaCounter47035968 != 'undefined') {
          yaCounter47035968.reachGoal('AddTipOrdinary');
          if (typeof tip_text !== 'undefined') {
            yaCounter47035968.reachGoal('AddReviews');
          }
        }
      }
    }
  });
}
</script>

将箭头函数转换为 function 函数。

  window.sbHooks.addAction('sbCoreState::CreateBets/success', function(data, response) {
// the rest stays the same

您必须删除箭头,以便您的函数看起来像:

window.sbHooks.addAction('sbCoreState::CreateBets/success', function (data, response) {