<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://#/hm.js?bcf4b9aa718c44d0552ca883aed26b42";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
* plugins文件-新建track.ts
import _Vue from 'vue'
type PluginFunction<T> = (Vue: typeof _Vue, options?: T) => void
interface PluginObject<T> {
install: PluginFunction<T>;
[key: string]: any;
}
const VueTrack:PluginObject<any> = {
install: () => {}
}
VueTrack.install = (Vue: typeof _Vue) => {
function trackEvent(...arg:any) {
const _hmt = window._hmt || []
_hmt.push(['_trackEvent', arg]) //百度統(tǒng)計(jì)
// 增加實(shí)時(shí)查看
// 文檔地址:
// http://doc.talkingdata.com/posts/36](http://doc.talkingdata.com/posts/36)
// html - 》head-》引入sdk <script src="https://jic.talkingdata.com/app/h5/v1?appid=1A39A61C5DAE4FD3BB35D55019381CCC&vn=web&vc=2"></script>
// 設(shè)置全局變量TDAPP type->shims-tsx.d.ts
)
if (arg.length > 2) {
const kv = { [arg[2]]:arg[3] }
window.TDAPP.onEvent(arg[1], arg[2], kv)
} else {
window.TDAPP.onEvent(arg)
}
}
Vue.prototype.$track = trackEvent
}
export default VueTrack
- 最后項(xiàng)目直接使用this.$track('事件id',‘參數(shù)1’,‘參數(shù)2’,‘參數(shù)3’)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。