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

177
Views
¿Cómo uso la propiedad desde dentro de vue- hacia fuera de vue?

Estoy usando vue2.5. Simplemente intento que una variable fuera de vue (javascript tradicional o jquery) acceda a una propiedad del modelo vue. La propiedad en este caso es sol. Quiero que los datos que se encontrarían en el sol se muestren en el planeta Const. ¿Cómo puedo hacer que funcione? Intenté usar const planet = $app.sun pero eso no funciona. No estoy seguro de cómo hacer que esto funcione. Por favor vea mi ejemplo

 const planet="" //document.getElementById("cat").append("myName"); new Vue({ el: "#app", data: { earth:"this is a ball", sun:"s", }, methods: { toggle: function(){ this.sun="a ball of stars" } } })
 <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="app"> {{sun}} <br> <button v-on:click="toggle()">magic </button> <div id="planet"> </div> </div>

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

0

Puede configurar Vue en variable y luego acceder a $data :

 var vm = new Vue({ el: "#app", data: { earth:"this is a ball", sun:"s" }, methods: { toggle: function(){ this.sun="a ball of stars" } } }) const planet = vm.$data.sun document.getElementById("cat").append(planet);
 <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="app"> {{sun}} <br> <button v-on:click="toggle()">magic</button> <div id="planet"> </div> </div> <p>outside of Vue</p> <div id="cat"></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!