[bugfix] Dialog: cancel button display (#2685)

This commit is contained in:
neverland 2019-02-05 11:15:47 +08:00 committed by GitHub
parent 4374293c4e
commit b896113ad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 21 deletions

View File

@ -88,8 +88,8 @@ export default sfc({
const hasButtons = this.showCancelButton && this.showConfirmButton; const hasButtons = this.showCancelButton && this.showConfirmButton;
const ButtonGroup = ( const ButtonGroup = (
<div class={['van-hairline--top', bem('footer', { buttons: hasButtons })]}> <div class={['van-hairline--top', bem('footer', { buttons: hasButtons })]}>
{this.showCancelButton && (
<Button <Button
vShow={this.showCancelButton}
size="large" size="large"
class={bem('cancel')} class={bem('cancel')}
loading={this.loading.cancel} loading={this.loading.cancel}
@ -98,8 +98,9 @@ export default sfc({
this.handleAction('cancel'); this.handleAction('cancel');
}} }}
/> />
)}
{this.showConfirmButton && (
<Button <Button
vShow={this.showConfirmButton}
size="large" size="large"
class={[bem('confirm'), { 'van-hairline--left': hasButtons }]} class={[bem('confirm'), { 'van-hairline--left': hasButtons }]}
loading={this.loading.confirm} loading={this.loading.confirm}
@ -108,6 +109,7 @@ export default sfc({
this.handleAction('confirm'); this.handleAction('confirm');
}} }}
/> />
)}
</div> </div>
); );

View File

@ -7,7 +7,10 @@ transitionStub();
test('Dialog function call', async () => { test('Dialog function call', async () => {
Dialog.close(); Dialog.close();
Dialog.alert('1'); Dialog.alert({
message: '1',
showCancelButton: true
});
await later(); await later();
@ -35,6 +38,7 @@ test('before close', () => {
const wrapper = mount(DialogVue, { const wrapper = mount(DialogVue, {
propsData: { propsData: {
value: true, value: true,
showCancelButton: true,
beforeClose: (action, done) => done(false) beforeClose: (action, done) => done(false)
} }
}); });