vue-ba
Advanced tools
Comparing version 1.2.5 to 1.2.6
{ | ||
"name": "vue-ba", | ||
"version": "1.2.5", | ||
"version": "1.2.6", | ||
"description": "baidu analystics vue module", | ||
@@ -5,0 +5,0 @@ "author": "minlingchao<mrminlingchao@gmail.com>", |
@@ -86,2 +86,4 @@ # vue-ba | ||
统计自定义事件使用 v-track-event.someEvent.custom | ||
#### 用法 | ||
@@ -96,2 +98,4 @@ | ||
<input v-track-event.someEvent.custom="'category, action'"> // 统计someEvent事件,someEvent是自定义事件 | ||
<button v-track-event="'category, action, opt_label, opt_value'"><button> // 以字符串传递参数 | ||
@@ -98,0 +102,0 @@ |
import ba from '../index' | ||
import { notChanged, isEmpty } from './utils' | ||
export default function (el, binding) { | ||
export default function (el, binding, vnode) { | ||
if (notChanged(binding) || isEmpty(binding)) { | ||
@@ -29,5 +29,11 @@ return | ||
events.forEach((event) => { | ||
el.addEventListener(event, () => ba.trackEvent(...args), false) | ||
events.forEach((eventValue) => { | ||
const customTag = 'custom' | ||
let [event, custom] = eventValue.split(':') | ||
if (custom === customTag) { | ||
vnode.componentInstance.$on(event, () => ba.trackEvent(...args), false) | ||
} else { | ||
el.addEventListener(event, () => ba.trackEvent(...args), false) | ||
} | ||
}) | ||
} |
288092
912
120
37