vue 公眾號開放標籤跳轉小程式 wx-open-launch-weapp
阿新 • • 發佈:2021-08-11
//在main.js裡新增程式碼 Vue.config.ignoredElements = ['wx-open-launch-weapp'];
<template> <div> <wx-open-launch-weapp id="launch-btn" username="gh_747fd668e2a6" path="pages/core/web?url=https://phar.linkdoc.com/open/redirect/immunity_online?openid=oRI_g1VF_xNOUm095jMmJvGkWKDw&scanid=01f485d5-7edf-4279-a089-1df1fb3849ba&pagePath=%2Fsubpkg_order%2Fpages%2FreservationOrder%2Findex%3FprojectQrCode%253D4"> <script type="text/wxtag-template"> <style>.btn { padding: 12px}</style> <button class="btn">跳轉小程式</button> </script> </wx-open-launch-weapp> </div> </template> <script> import { mapState, mapMutations, mapActions }from "vuex"; export default { data() { return {} }, created() { this.getWxConfig(location.href); }, mounted() { this.$store.state.showMenu = false var btn = document.getElementById('launch-btn'); btn.addEventListener('launch', function (e) { console.log('success'); }); btn.addEventListener('error', function (e) { console.log('fail', e.detail); }); }, methods: { ...mapActions({ getWxConfig: "getWxConfig" }) } } </script>