황소 기술 공유

1474 단어

vue.js


router --
Vue.component( "myApp",{ props:["myMsg","myData"], data:function () { return { content:"" } }, template:` <div> <h1>{{myMsg}}</h1> <input type="text" v-model="content"> <my-list :my-data="myData" @myEvent="changeValue"></my-list> </div> `, methods:{ changeValue(msg){ this.content=msg } } }); Vue.component( "myList",{ props:["myData"], template:` <div> <ul> <li v-for="num in myData" @click="myClick(num)">{{num}}</li> </ul> </div> `, methods:{ myClick(num){ this.$emit("myEvent",num); } } }); var vm = new Vue({ el:"#app", data:{ msg:"Hello", msg2:"Vue", data1:[11,22,33,44], data2:[55,66,77,88] } });

좋은 웹페이지 즐겨찾기