// 定义自定义指令
import { Directive } from 'vue'
const point: Directive = {
mounted(el, binding) {
const params = {
triggerType: binding.value.triggerType, // 触发事件
UserName: binding.value.UserName, // 用户名
IpAddress: binding.value.IpAddress, // ip地址
OperationType: binding.value.OperationType, // 操作类型
ModuleName: binding.value.ModuleName, // 模块名称
EventDescription: binding.value.EventDescription, // 事件描述
OperationTime: binding.value.OperationTime, // 操作时间
EventLevel: binding.value.EventLevel, // 事件等级
EventOutcome: binding.value.EventOutcome // 事件结果
}
console.log('el', el)
console.log('binding', binding.value.triggerType)
const data = binding.value
if (data) {
if (data.triggerType == 'click') {
el.addEventListener('click', () => {
console.log('params', params)
})
}
} else {
throw new Error('请补充正确的埋点参数')
}
}
}
export default point
<img
:src="calendar"
alt=""
@click="showDaily()"
v-point="{
triggerType: 'click',
UserName: 'admin',
IpAddress: '10.1.19.16',
OperationType: '查看防汛PDF',
ModuleName: bg,
EventDescription: '用户[admin]查看了' + bg,
OperationTime: new Date().toLocaleString(),
EventLevel: '-',
EventOutcome: '成功'
}"
/>
vue埋点
最新推荐文章于 2024-08-21 22:17:11 发布