Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
La variable data () se niega a actualizar cuando se establece dentro de funciones anidadas

Soy muy nuevo en VUE, así que disculpe si mi terminología no es correcta.

Estoy tratando de establecer una variable que se define en la función "datos ()" de la etiqueta del script.

Estoy tratando de establecer un nuevo valor para una variable definida en data() desde dentro del evento de ciclo de vida "creado()". Esto funciona bien si se hace en el nivel raíz, pero necesito hacerlo dentro de 2 llamadas anidadas como se muestra a continuación y no funcionará cuando esté anidado dentro de las llamadas a funciones:

aplicación.vue

 <template> <div class="container"> <Button @btn-click="providerPicked" id="current-provider" :text="'Current Provider: ' + currentProvider" /> </div> </template> <script> import { ZOHO } from "./assets/ZohoEmbededAppSDK.min.js"; import Button from './components/Button' export default { name: 'App', components: { Button, }, data() { return{ currentProvider: 'x' } }, created() { console.log("CREATED HOOK") ZOHO.embeddedApp.on("PageLoad",function(data) { console.log(data); //Custom Business logic goes here let entity = data.Entity; let recordID = data.EntityId[0]; ZOHO.CRM.API.getRecord({Entity:entity,RecordID:recordID}) .then(function(data){ console.log(data.data[0]) console.log(data.data[0].name) //THIS DOES NOT WORK - variable still comes back 'x' in template, notice this is nested twice. this.currentProvider = data.data[0].name; }); }); ZOHO.embeddedApp.init(); //THIS DOES WORK - SETS VAR TO "reee" in template, notice this is not nested this.currentProvider = "reee" } } </script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Utilice funciones de flecha en lugar de funciones anónimas.

Las funciones de flecha no vinculan this y, por lo tanto, this se referirá al ámbito externo.

 created() { console.log("CREATED HOOK") ZOHO.embeddedApp.on("PageLoad", (data) => { console.log(data); //Custom Business logic goes here let entity = data.Entity; let recordID = data.EntityId[0]; ZOHO.CRM.API.getRecord({ Entity: entity, RecordID: recordID }) .then((data) => { console.log(data.data[0]) console.log(data.data[0].name) //THIS DOES NOT WORK - variable still comes back 'x' in template, notice this is nested twice. this.currentProvider = data.data[0].name; }); }); ZOHO.embeddedApp.init(); //THIS DOES WORK - SETS VAR TO "reee" in template, notice this is not nested this.currentProvider = "reee" }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!