Answer the question
In order to leave comments, you need to log in
How to set a property in such a construction?
I don't know Js well. I have always used vue templates for simple actions like reactive forms, ajax requests, etc. It was necessary to implement smart buttons for PayPal. Googled this option
<template>
<span>
<b-spinner
v-if="spinner"
></b-spinner>
<div v-show="!spinner" ref="paypal" class="mt-3"></div>
</span>
</template>
<script>
export default {
data() {
return {
spinner: false,
};
},
mounted: function () {
const script = document.createElement("script");
const ClientID = this.client_id;
script.src = `https://www.paypal.com/sdk/js?client-id=${ClientID}`;
script.addEventListener("load", this.setLoaded);
document.body.appendChild(script);
},
methods: {
setLoaded: function () {
window.paypal
.Buttons({
createOrder: function() {
},
onApprove: function (data) {
this.spinner = true
return axios
.post(route_capture_order)
.then(function (res) {
return res.data;
})
.then(function (details) {
this.spinner = false;
window.location.reload(false);
});
},
})
.render(this.$refs.paypal);
},
},
};
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question