亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

添加谷歌分析事件后,vue 點擊事件被破壞?

添加谷歌分析事件后,vue 點擊事件被破壞?

開滿天機 2023-08-18 14:01:05
我在 vue 中的鏈接上有一個點擊事件,該鏈接啟動了一個模式,該模式有一個鏈接將用戶引導到另一個網站。一切都按預期工作,直到我剛剛添加了谷歌分析點擊事件?,F在模式打開,但到另一個站點的鏈接只是返回到主頁 /root。有沒有辦法在不中斷的情況下調用鏈接上的兩個點擊事件?啟動模式并鏈接出的鏈接:             <a              href="https://www.linkout.com"              rel="noopener"              @click.prevent="                openInterstitial;                $ga.event('link', 'click', 'ISI_link');              "              target="_blank"              >www.linkout.com</a            >mixin method:Vue.mixin({  methods: {      openInterstitial(event) {        if (event) {          event.preventDefault();          this.$store.commit('modals/setInterstitialHref', event.target.href);        }        this.$store.commit('modals/setShowInterstitial', true);      }    }  });店鋪export const state = () => ({  interstitial: {    show: false,    href: ''  }});export const mutations = {  setShowInterstitial(state, boolean) {    state.interstitial.show = boolean;  },  setInterstitialHref(state, string) {    state.interstitial.href = string;  }};
查看完整描述

1 回答

?
炎炎設計

TA貢獻1808條經驗 獲得超4個贊

我重現了您的問題,似乎您的openInterstitial方法根本沒有被調用。問題是您使用該方法來訪問事件數據(不帶括號的用法)。因此,你不能像以前那樣鏈接它們,它不會被執行。如果您使用單個處理程序,則只能省略括號。

您可以做的是使用帶括號的方法并使用$event(?Docs?) 傳遞事件數據。

@click.prevent="
??openInterstitial($event);
??$ga.event('link',?'click',?'ISI_link');
"

這樣您就可以訪問事件數據并鏈接多個方法。希望能解決您的問題!



查看完整回答
反對 回復 2023-08-18
  • 1 回答
  • 0 關注
  • 117 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號