美文网首页
vue2忽略微信组件

vue2忽略微信组件

作者: IamaStupid | 来源:发表于2023-10-26 10:22 被阅读0次

    使用情景,vue页面需要加一个微信公众号订阅按钮

    // article.vue

    <div class="btn-box">
          <template>
            <wx-open-subscribe template="xxx订阅模板" id="subscribe-btn">
              <!-- <script type="text/wxtag-template" slot="style">
                <style>
                  .subscribe-btn {
                    color: #fff;
                    background-color: #07c160;
                  }
                </style>
              </script> -->
              <script type="text/wxtag-template">
                <button class="link-btn">
                  订阅              
                </button>
              </script>
            </wx-open-subscribe>
          </template>
        </div>
    

    这样是会报错的,会提示wx-open-subscribe这个组件没注册。

    所以为了解决这个问题,需要将它忽略:

    // main.js
    
    Vue.config.ignoredElements = ['wx-open-subscribe']
    

    相关文章

      网友评论

          本文标题:vue2忽略微信组件

          本文链接:https://www.haomeiwen.com/subject/hkmyidtx.html