vue项目 神策统计 配置插件
npm install vue-sensors-plugin> 用户行为分析、 统计
javascript
resolve: {
alias: {
'@': resolve('src')
...
}
}
`
$3
`javascript main.js
import SensorsPlugin from 'vue-sensors-plugin';
Vue.use(SensorsPlugin, {
name: 'sensors',
heatmap: {
clickmap: 'default', // $webClick sensors.quick('autoTrack')
scroll_notice_map: 'default', // $webStay
scroll_delay_time: 4000
}
}); // 神策统计 初始化
// 路由切换的时候调用 $pageView
router.afterEach((to, from) => {
Vue.nextTick(() => {
window.sensors.quick('autoTrackSinglePage');
});
});
`
$3
- config/index.js中区分环境, 配置字段 sensors
`javascript config/index.js
module.exports = {
dev: {
....
sensors: {
server_url: 'xxxxx',
name: 'xxx',
heatmap: { .... }
}
},
build: {
....
sensors: {
server_url: 'xxxxx',
name: 'xxx',
heatmap: { .... }
}
}
}
`
$3
$3
- 引入 main.js, 通过 根目录的config/index.js中区分环境, 配置字段 sensors
- import SensorsPlugin from 'vue-sensors-plugin';
- Vue.use(SensorsPlugin, { name: 'sensors' // default }) 第二个参数可选, 此配置优先级高于 根目录的config/index.js 中的 sensors字段
`html
- 调用
`html
``