Shopify 变体产品 - 未捕获的类型错误:无法读取 null 的属性“样式”

问题描述

我在 Shopify 网站上工作,并试图关闭 4 件装的订阅选项。

我有这个代码,但我遇到了一个我不熟悉的错误。希望有人能指出我正确的方向来修复。谢谢!

网站: https://crispandcrude.myshopify.com/products/mellow-mule密码susahx

错误 “未捕获的类型错误:无法读取 null 的属性‘样式’”

enter image description here

代码

/* ======================================
    disABLE 4 Pack Subscriptions
========================================= */
window.addEventListener('DOMContentLoaded',(event) => {

  let noSub = '4 Pack'
  let variants = document.querySelectorAll('[data-value]');
  let rechargeForm = document.querySelector('.rc_container')
  let initialCheckedValue = document.querySelector('.swatch input:checked')


  // On variant change
  variants.forEach(variant =>
                   variant.addEventListener('click',e=> {
    if (e.target.value == noSub) {
      // Hide RC widget and click first/one time option          
      rechargeForm.style.display = 'none'
      document.querySelector('.rc_widget__option--onetime input').click();
    } else {
      rechargeForm.style.display = 'block'
    }
  })
                  )

  // On first load
  if (initialCheckedValue.value == noSub) {
    // Hide RC widget and click first/one time option
    rechargeForm.style.display = 'none'
    document.querySelector('.rc_widget__option--onetime input').click();
  } else {
    rechargeForm.style.display = 'block'
  }

});

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)