diff --git a/src/form/link.js b/src/form/link.js index 59cdbae..4ceaed3 100644 --- a/src/form/link.js +++ b/src/form/link.js @@ -4,7 +4,7 @@ * @date 2023/03/16 17:40:50 */ -import { css, html, Component, bind, unbind, nextTick } from 'wkit' +import { css, html, Component, bind, nextTick } from 'wkit' class Link extends Component { static props = { @@ -106,6 +106,11 @@ class Link extends Component { ` ] + #stop(ev) { + ev.preventDefault() + ev.stopPropagation() + } + mounted() { this.stamp = 0 @@ -113,7 +118,7 @@ class Link extends Component { nextTick(_ => this.$refs.a.focus()) } - this._clickFn = bind( + bind( this.$refs.a, 'click', ev => { @@ -122,15 +127,11 @@ class Link extends Component { // 除了事件冒泡之外, a标签的默认事件也要阻止 if (disabled) { - ev.preventDefault() - ev.stopPropagation() - return + return this.#stop(ev) } // 并发拦截 if (lazy > 0 && now - this.stamp < lazy) { - ev.preventDefault() - ev.stopPropagation() - return + return this.#stop(ev) } this.stamp = now }, @@ -141,7 +142,7 @@ class Link extends Component { render() { return html` - + ` }