vue中友盟站长代码统计实现
- 2019 年 10 月 8 日
- 筆記
<template>
<div class="footer" id="foot"> <p id="test" class="company">{{$t('other.footerDes')}}</p> </div>
</template>
mounted() {
const script = document.createElement('script') script.src = 'https://s95.cnzz.com/z_stat.php?id=1256769433&web_id=1256769433' script.language = 'JavaScript' document.getElementById('test').appendChild(script) const script1 = document.createElement('script') script1.src = 'https://c.cnzz.com/core.php?web_id=1256769433&t=z' script1.language = 'JavaScript' document.getElementById('test').appendChild(script1) const a = document.createElement('a') a.href = 'https://www.cnzz.com/stat/website.php?web_id=1256769433' a.text = ' 站长统计' a.title = '站长统计' a.style = 'font-size:14px;color:#FFFFFF' document.getElementById('test').appendChild(a) }
,watch: { '$route' () { if (window._czc) { let location = window.location let contentUrl = location.pathname + location.hash let refererUrl = '/' window._czc.push(['_trackPageview', contentUrl, refererUrl]) } } }
实现效果