Questions tagged «vue-resource»

9
Vue.js-如何正确监视嵌套数据
我正在尝试了解如何正确观察道具的一些变化。我有一个父组件(.vue文件),该组件从ajax调用接收数据,将数据放入对象中,并通过v-for指令使用它来呈现某些子组件,以下是我的实现的简化: <template> <div> <player v-for="(item, key, index) in players" :item="item" :index="index" :key="key""> </player> </div> </template> ...然后在<script>标签内: data(){ return { players: {} }, created(){ let self = this; this.$http.get('../serv/config/player.php').then((response) => { let pls = response.body; for (let p in pls) { self.$set(self.players, p, pls[p]); } }); } 项目对象是这样的: item:{ prop: value, …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.