vue中友盟站长代码统计实现

2019-09-29 14:52:42 浏览数 (2)

代码语言:javascript复制
<template>
代码语言:javascript复制
<div class="footer" id="foot">
        <p id="test" class="company">{{$t('other.footerDes')}}</p>
</div>
代码语言:javascript复制
</template>
代码语言:javascript复制
mounted() {
代码语言:javascript复制
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)
}
代码语言:javascript复制
,watch: {
    '$route' () {
        if (window._czc) {
            let location = window.location
            let contentUrl = location.pathname   location.hash
            let refererUrl = '/'
            window._czc.push(['_trackPageview', contentUrl, refererUrl])
        }
    }
}

实现效果

0 人点赞