<template>
<b-button v-if="btnLoading"
variant="outline-warning"
class="d-block text-white text-uppercase"
disabled>
Подождите <i class="fas fa-spinner fa-spin"></i>
</b-button>
<b-button v-else="btnLoading" variant="outline-warning"
class="d-block text-white text-uppercase"
@click="buy()">
Купить за {{ product.original_price }} руб.
</b-button>
</template>
<script>
data() {
return {
tabIndex: 0,
firstServer: {},
product: {},
order: {
nickname: '',
productId: ''
},
btnLoading: false
}
},
</script>
<template>
<b-button
variant="outline-warning"
class="d-block text-white text-uppercase"
:disabled="btnLoading"
>
<span v-text="buttonText"></span>
<i class="fas fa-spinner fa-spin" v-if="btnLoading"></i>
</b-button>
</template>
<script>
...
data() {
return {
tabIndex: 0,
firstServer: {},
product: {},
order: {
nickname: '',
productId: ''
},
btnLoading: false
}
},
computed: {
buttonText() {
return this.btnLoading
? 'Подождите'
: `Купить за ${ this.product.original_price } руб.`;
}
}
...
</script>