1. <wx-open-launch-weapp
    2. id="launch-btn"
    3. class="opentag"
    4. username="gh_6b4d28fdb9fe"
    5. path="/pages/index/index.html"
    6. @launch="handleLaunchFn"
    7. @error="handleErrorFn"
    8. >
    9. <component
    10. :is="'script'"
    11. type="text/wxtag-template"
    12. style="display: block"
    13. >
    14. <div style="margin: 16px">
    15. <button
    16. style="
    17. width: 295px;
    18. height: 42px;
    19. color: white;
    20. text-align: center;
    21. background: rgb(25, 137, 250);
    22. border: 1px solid rgb(25, 137, 250);
    23. border-radius: 21px;
    24. "
    25. >
    26. 注册
    27. </button>
    28. </div>
    29. </component>
    30. </wx-open-launch-weapp>
    1. const wxConfig = async () => {
    2. const params = {
    3. url: encodeURIComponent(location.href.split("#")[0]),
    4. };
    5. const { data } = await signature(params);
    6. wx.config({
    7. debug: false,
    8. appId: "wx83b985f77106165c", // 公众号id
    9. timestamp: data.timestamp, // 后端提供
    10. nonceStr: data.noncestr, // 后端提供
    11. signature: data.signature, // 后端提供
    12. jsApiList: [
    13. "scanQRCode",
    14. "updateAppMessageShareData",
    15. "updateTimelineShareData",
    16. ], // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
    17. openTagList: ["wx-open-launch-weapp"],
    18. });
    19. wx.ready(function () {
    20. console.log("config ready");
    21. });
    22. wx.error(function (errMsg: string) {
    23. console.log("config error", errMsg);
    24. });
    25. };

    wxConfig() 可以初始调用,也可以在接口后面调用

    1. Vue.config.ignoredElements = [
    2. "wx-open-launch-app",
    3. "wx-open-launch-weapp",
    4. ];