😎优化 v-reclick 指令
This commit is contained in:
parent
8cb0417685
commit
51400baea5
@ -182,23 +182,28 @@ export function dragDirective(app: App) {
|
||||
* @directive 默认方式:v-reclick,如 `<el-button v-reclick></el-button>`
|
||||
* @directive 参数方式:v-reclick="number",如 `<el-button v-reclick="500"></el-button>`
|
||||
*/
|
||||
export function reclickDirective(app: App) {
|
||||
export function reclickDirective(app: App) {
|
||||
let opacity = '';
|
||||
app.directive('reclick', {
|
||||
mounted(el, time) {
|
||||
el.addEventListener('click', () => {
|
||||
if (!el.disabled) {
|
||||
el.disabled = true;
|
||||
opacity = el.style.opacity;
|
||||
el.style.opacity = '0.2';
|
||||
setTimeout(
|
||||
() => {
|
||||
el.disabled = false;
|
||||
el.style.opacity = opacity;
|
||||
},
|
||||
time.value === undefined ? 500 : time.value
|
||||
time.value === undefined ? 800 : time.value
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
unmounted(el) {
|
||||
el.disabled = false;
|
||||
el.style.opacity = opacity;
|
||||
},
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user