Vzupo
Vzupo

Reputation: 1478

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

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>

Upvotes: 0

Views: 235

Answers (1)

Nikola Pavicevic
Nikola Pavicevic

Reputation: 23500

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>

Upvotes: 1

Related Questions