Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
Workarounds to using this in Vue

I am attempting to create a PayPal checkout order on my Vue site. I am currently passing two props to the component as well as two data objects

  props: {
    price: Number,
    shipping: Number,
  },
  data() {
    return {quantity: 1, switches: 'red'}
  },

I am referencing these four variables in my code as this.price, this.shipping etc. I have confirmed these are all valid

I am attempting to access these inside a method but this is being over-ridden and all four of these are undefined.

I still don't quite understand this, but I was under the impression that using an arrow function as I have done should stop this from changing. Is this not the case?

Code

   await paypal.Buttons({
      style: {
        layout: 'vertical',
        color: 'black',
        shape: 'pill',
      },
      createOrder: (data, actions) => {
        return actions.order.create({
          purchase_units: [{
            amount: {
              currency_code: "USD",
              value: ((this.price + this.shipping) * this.quantity).toString(),
              breakdown: {
                item_total: {  /* Required when including the `items` array */
                  currency_code: "USD",
                  value: this.price.toString()
                },
                shipping: {
                  currency_code: "USD",
                  value: this.shipping.toString()
                }
              }
            },
            items: [
              {
                name: "First Product Name", /* Shows within upper-right dropdown during payment approval */
                description: "Optional descriptive text..", /* Item details will also be in the completed paypal.com transaction view */
                unit_amount: {
                  currency_code: "USD",
                  value: this.price.toString()
                },
                quantity: this.quantity.toString
              },
            ]
          }]
        });
      },
    }).render('#paypal-button-container')
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda