关于最新的公众号订阅消息,vue 项目你只需要这样
发布于 4 年前 作者 yangyang 4021 次浏览 来自 分享
<template>
    <wx-open-subscribe
        id="wechatSubscribe"
        :style="style" 
        :template="templates.join(',')"
        @success="wechatSubscribeSuccess"
        @error="wechatSubscribeError"
    >
        <script type="text/wxtag-template">
            <style>
            .subscribe-btn {
            width100%;
            height100px;
            display: block;
            }
            </style>
            <button class="subscribe-btn">scribe</button>
        </script>
    </wx-open-subscribe>
</template>

<script>
// 给嵌套它的父级设置 position: relative 等。
export default {
    props: {
        templates: {
            typeArray,
            default() => [],
        },
        width: {
            typeString,
            default'100%',
        },
        height: {
            typeString,
            default'100%',
        },
        top: {
            typeString,
            default'0',
        },
        left: {
            typeString,
            default'0',
        },
    },
    computed: {
        style() {
            return `position: absolute;top: ${this.top || 0}; left: ${this.left || 0}; width: ${this.width}; height: ${this.height};opacity: 0; z-index: 100;`
        },
    },
    methods: {
        wechatSubscribeSuccess(e) {
            this.$emit('on-ok');
        },
        wechatSubscribeError(e) {
            this.$emit('on-ok');
        },
    },
}
</script>

1 回复

返回的  e.detail对象为{}这个你有遇到吗

回到顶部