当 .btn 仅定义 class 时,Shopify 添加 .text-link class 到按钮

Shopify adding .text-link class to button when .btn is only class defined

在自定义 Shopify 页面时,我添加了一个 class 只有

的动态按钮
{% if section.settings.button_label != blank and section.settings.button_link != blank %}
         <a href="{{ section.settings.button_link }}" class="btn">
           {{ section.settings.button_label | escape }}
         </a>
{% endif %}

但是,当页面加载时,它现在已将 .text-link 附加到我的按钮 classes,覆盖了按钮的样式。

    a.btn.text-link {
      -webkit-appearance: none;
    background-color: #2c2d36;
    background-image: none;
    border: 1px solid transparent;
    border-bottom: 1px solid #2c2d36;
    border-radius: 0;
    box-sizing: border-box;
    color: #fff;
    cursor: pointer;
    display: inline-block;
    font-family: Futura,sans-serif;
    font-size: .8125em;
    font-weight: 700;
    letter-spacing: .1em;
    line-height: 1.42;
    margin: 0;
    padding: 8px 10px;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    transition: background-color .4s ease-out;
    user-select: none;
    vertical-align: middle;
    white-space: normal;
    width: auto;
    }

任何人都知道我应该在哪里阻止它附加到我的单曲中 class?

Link: https://shop.creekretreat.com/pages/services (第一个 image/text 部分的按钮组)

提前致谢,非常感谢。

K

您的 theme.js 中有一个 JS 函数正在执行此操作:

theme.styleTextLinks = function() {
  $('.rte').find('a:not(:has(img))').addClass('text-link');
};

这个函数在theme.init方法中被调用:

theme.init = function() {
  theme.initCache();
  theme.setBreakpoints();
  theme.fitNav();
  theme.cartInit();
  theme.afterCartLoad();
  theme.checkoutIndicator();
  theme.returnLink();
  theme.styleTextLinks(); <----- here
  ......

您将需要更新 JS 以满足您的需要或一起删除此逻辑。