<script type="text/javascript">
window.__STATE__ = <?= json_encode($allData) ?>;
</script>
created () {
if (window.__STATE__ && window.__STATE__.myData) {
this.myData = window.__STATE__.myData;
} else {
axios.get( .... )
}
}
function getData() {
//...
return new Promise((resolve, reject) => {
xhr.onreadystatechange = function () {
if (xhr.readyState != 4) reject(xhr.statusText);
if (xhr.status != 200) {
reject(xhr.statusText);
} else {
resolve(xhr.responseText);
}
};
xhr.send();
});
}
// use
getData()
.then(function(response){
console.log('Its OK', response);
})
.catch(function(errorText){
console.log('Error:', errorText);
});
<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>
Фон менял сам!
/*box-shadow: 0 0 4px 2px #ffffffe6;*/
/*background: #ffffffe6;*/
box-shadow: 0 0 4px 2px rgba(255, 255, 255, 0.9);
background: rgba(255, 255, 255, 0.9);