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

121
Views
Actualización de datos de acuerdo con el valor de accesorios en el archivo Vue que devuelve un mensaje de error no definido

Estoy tratando de cambiar los datos según el valor de mis accesorios en una aplicación Nuxtjs.

 export default { props: { moved: { default: false, type: Boolean, } }, data: function () { if (!this.moved){ dataName: { fill: "value1" } else dataName: { fill: "value2" } return dataName } } }

Pero tengo un mensaje de error que me dice que dataName is not defined . No se que estoy haciendo mal aqui...

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En su lugar, puede hacer una propiedad calculada:

 Vue.component('Child', { template: ` <div> {{ dataName }} <svg height="210" width="500"> <polygon points="100,10 40,198 190,78 10,78 160,198" :fill="dataName.fill"/> </svg> </div> `, props: { moved: { default: false, type: Boolean, } }, computed: { dataName() { let mov = {} this.moved ? mov.fill = 'blue' : mov.fill = 'red' return mov } } }) new Vue({ el: '#demo', data() { return { moved: false } }, methods: { changeMov() { this.moved = !this.moved } } }) Vue.config.productionTip = false Vue.config.devtools = false
 <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="demo"> <button @click="changeMov">Change</button> <Child :moved="moved" /> </div>

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!