import type { DirectiveBinding } from 'vue';
import { Directive } from 'vue';

interface ElType extends HTMLElement {
	copyData: string | number; // 定义一个属性，用于存储需要复制的数据
	__handleClick__: any; // 定义一个属性，用于存储事件处理函数
}

const vPrint: Directive = {
	mounted(el: ElType, binding: DirectiveBinding) {
		el.copyData = binding.value;
		el.addEventListener('click', handelClick);
	},
	beforeMount(el: ElType) {
		el.removeEventListener('click', el.__handleClick__);
	},
};

function handelClick(this: any) {
	print();
}

export default vPrint;
