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

73
Views
vue - data reference another data

I very new in vue, how can mylist random, can get the same value from somerandom

export default {
  data () {
    return {
        somerandom:"foo",
        mylist:{
            random: this.somerandom
        }
    }
  }
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can try with computed property:

new Vue({
  el: '#demo',
  data () {
    return {
        somerandom:"foo",
        mylist:{
            random: ''
        }
    }
  },
  computed: {
    rand() {
      return this.mylist.random = this.somerandom
    }
  }
})

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">
    <p>{{ rand }}</p>
</div>

about 4 years ago · Juan Pablo Isaza Report

0

model init an object with value. can set value by default or run func after computed or mounted


data() {
    return {
      somerandom: '',
      someOther: [],
    }
},
computed: {
    useRandom() {
        this.somerandom = this.rand();
    }
},
methods: {
    rand(){
       return 'random';
    }
}
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!