1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| import { onBeforeUnmount, onMounted, reactive } from '@vue/runtime-core'; export default function (param) { let mpoint = reactive({ x: 0, y: 0 }); function savePotin(event) { mpoint.x = event.pageX; mpoint.y = event.pageY; param.title = param.title + '-hook'; console.log('param', param); console.log('mouse click point,', event.pageX, event.pageY); } onMounted(() => { window.addEventListener('click', savePotin); }); onBeforeUnmount(() => { window.removeEventListener('click', savePotin); }); return { mpoint, param }; }
|