diff --git a/packages/dialog/Dialog.js b/packages/dialog/Dialog.js index 13c7dff84..2d2163ba9 100644 --- a/packages/dialog/Dialog.js +++ b/packages/dialog/Dialog.js @@ -88,26 +88,28 @@ export default sfc({ const hasButtons = this.showCancelButton && this.showConfirmButton; const ButtonGroup = ( <div class={['van-hairline--top', bem('footer', { buttons: hasButtons })]}> - <Button - vShow={this.showCancelButton} - size="large" - class={bem('cancel')} - loading={this.loading.cancel} - text={this.cancelButtonText || t('cancel')} - onClick={() => { - this.handleAction('cancel'); - }} - /> - <Button - vShow={this.showConfirmButton} - size="large" - class={[bem('confirm'), { 'van-hairline--left': hasButtons }]} - loading={this.loading.confirm} - text={this.confirmButtonText || t('confirm')} - onClick={() => { - this.handleAction('confirm'); - }} - /> + {this.showCancelButton && ( + <Button + size="large" + class={bem('cancel')} + loading={this.loading.cancel} + text={this.cancelButtonText || t('cancel')} + onClick={() => { + this.handleAction('cancel'); + }} + /> + )} + {this.showConfirmButton && ( + <Button + size="large" + class={[bem('confirm'), { 'van-hairline--left': hasButtons }]} + loading={this.loading.confirm} + text={this.confirmButtonText || t('confirm')} + onClick={() => { + this.handleAction('confirm'); + }} + /> + )} </div> ); diff --git a/packages/dialog/test/index.spec.js b/packages/dialog/test/index.spec.js index ad15dfa35..7b8ea669c 100644 --- a/packages/dialog/test/index.spec.js +++ b/packages/dialog/test/index.spec.js @@ -7,7 +7,10 @@ transitionStub(); test('Dialog function call', async () => { Dialog.close(); - Dialog.alert('1'); + Dialog.alert({ + message: '1', + showCancelButton: true + }); await later(); @@ -35,6 +38,7 @@ test('before close', () => { const wrapper = mount(DialogVue, { propsData: { value: true, + showCancelButton: true, beforeClose: (action, done) => done(false) } });