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

172
Views
updating the list and re-render the vue-template

i have a scenario where on certain point the dropdown list of values are to be updated.like suppose we have a list of fruits in dropdown. on key-press i will update the the list of fruits with list of flowers this is just example. how can i update the list live? i read the reactivity in depth here but i didnt get much help from it.. this question is the part of this question here

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

0

new Vue({
  el: "#app",
  
  data: () => ({
type: 'fruits',
fruits: ['apple', 'banana', 'cherry'],
animals: ['cat', 'dog', 'rabbit'],
  }),
  
  computed: {
list() {
  return {
    fruits: this.fruits,
    animals: this.animals
  }[this.type]
}
  },
  
  methods: {
change(type){
  this.type = type
}
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <button @click.prevent="change('animals')">
    Animals
  </button>
  <button @click.prevent="change('fruits')">
    Fruits
  </button>
  
  <ul>
    <li v-for="item in list">{{ item }}</li>
  </ul>
</div>

Added a simple snippet to show how can be reactivity used to display list based on some option.

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!