diff --git a/develop.md b/develop.md index 8ee3005..28ad8b2 100644 --- a/develop.md +++ b/develop.md @@ -18,7 +18,7 @@ - +
diff --git a/src/form/button.js b/src/form/button.js index 088c60f..651175b 100644 --- a/src/form/button.js +++ b/src/form/button.js @@ -4,7 +4,7 @@ * @date 2023/03/06 15:17:25 */ -import { css, html, Component } from '@bd/core' +import { css, html, Component, $, nextTick } from '@bd/core' import '../icon/index.js' class Button extends Component { @@ -13,7 +13,19 @@ class Button extends Component { icon: '', size: 'l', autofocus: false, - loading: false, + loading: { + type: Boolean, + default: false, + observer(val) { + if (val) { + this.cacheIcon = this.icon + this.icon = 'loading' + } else { + this.icon = this.cacheIcon || '' + } + } + }, + list: Array, disabled: false, lazy: 0 // 并发拦截时间, 单位毫秒 } @@ -234,11 +246,21 @@ class Button extends Component { ) } + mounted() { + if (this.autofocus) { + let $btn = $('button', this.root) + $btn.setAttribute('autofocus', '') + // 需要focus()才能聚焦成功 + nextTick(_ => $btn.focus()) + } + } + render() { return html` ` }