2019/05/13

Vue.js 配列やオブジェクト







See the Pen Vue.js 配列やオブジェクト by takapen (@takapen) on CodePen.





{{ $data }}

  • {{ key }} : {{ item }}

{{ myArray }}

{{ myArray[0] }}

{{ myObject }}

{{ myObject.name }}-{{ myObject.num }}

{{ myObjectList }}

{{ myObjectList[1].name }}-{{ myObjectList[1].num }}








var list = [
  {name:'test1',num:1},
  {name:'test2',num:10}
]

new Vue({
  el:'#app',
  data:{
    myArray:['aaa','bbb','ccc'],
    myObject:{name:'test',num:1},
    myObjectList:list
  }
});