Home > Mobile >  Using Vuejs how do i display data from object and not array
Using Vuejs how do i display data from object and not array

Time:03-05

enter image description here

I am simply trying do displat this number found in my data model, but it is not an array so not sure what needs to be added for this to display. For arrays normally generatedData.Number would work, but not in this case. Any assistance would be great!

ew Vue({
  el: "#app",
  data: {
  generatedData:Object,Number:"14444"

  },
  methods: {
    toggle: function(todo){
        todo.done = !todo.done
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

<div id="app">
  my number is {{generatedData.Number}}
</div>

CodePudding user response:

If I understood you correctly try like following snippet:

new Vue({
  el: "#app",
  data() {
    return {
      generatedData: {
        Code: 'LA_100',
        isActive: true, 
        Name: '44445',
        Number: "14444"
      }
    }
  },
  methods: {
    toggle: function(todo){
        todo.done = !todo.done
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  my number is {{ generatedData.Number }}
</div>

  • Related