熟悉 Vue ?你能解释这个死循环吗?
栏目: JavaScript · 发布时间: 8年前
内容简介:把下面的代码拷到你的 html 文件,在浏览器打开你会看到控制台报了死循环的错,知道为什么吗?
把下面的代码拷到你的 html 文件,在浏览器打开你会看到控制台报了死循环的错,知道为什么吗?
<body>
<div id="app">
<child-comp v-for="i in [1]" :key="Math.random()" :sub-prop="parentData"></child-comp>
</div>
<script src="https://cdn.bootcss.com/vue/2.5.16/vue.js"></script>
Vue.component('child-comp', {
props: {
subProp: {}
},
data() {
return {
subData: []
};
},
template: '<div></div>',
computed: {
subComputed() {
return '222';
}
},
created() {
console.log(this.subComputed);
this.subData.push(1);
}
});
vm = new Vue({
el: '#app',
data() {
return {
parentData: 'hello world'
};
}
})
</script>
</body>
复制代码
以上所述就是小编给大家介绍的《熟悉 Vue ?你能解释这个死循环吗?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Linux Programming Interface
Michael Kerrisk / No Starch Press / 2010-11-6 / GBP 79.99
The Linux Programming Interface describes the Linux API (application programming interface)-the system calls, library functions, and other low-level interfaces that are used, directly or indirectly, b......一起来看看 《The Linux Programming Interface》 这本书的介绍吧!