[Vuejs]-Getting a variable from mounted into a method

0👍

You should store the Stripe instance on the Vue component itself so you can access it from other methods of that component:

mounted() {
  // Initialize Stripe
  this.stripe = Stripe('secret');

  // Blah blah more Stripe initialization code
},

methods: {
  performPayment() {
    // Now you can access the Stripe instance from this
    this.stripe.handleCardPayment(...)
  }
}

Leave a comment