组件无法访问以$开头的数据
我制作了一些混合物组件。
mixin1.vue
export default {
data(){
return {
$_mixin1_data1 : 'data1',
data2 : 'data2'
}
},
methods:{
$_mixin1_method1(){
}
}
}
parent.vue
import mixin1 from './mixin1';
export default {
name : 'Parent',
mixins:[mixin1],
data(){
return {
parent1 : 'parent1'
}
},
mounted(){
console.log(this.parent1); // parent1
console.log(this.$_mixin1_data1) //undefined
console.log(this.data2); //data2
}
}
当我将parent component与MixIn1组件一起使用时,父组件找不到以$ 开头的数据。但是“ data2”数据和以$ 开头的方法。我不知道为什么未检测到以$ _开头的数据。我可能不了解Vue的概念。 感谢您的答复。
I made some components with mixins.
mixin1.vue
export default {
data(){
return {
$_mixin1_data1 : 'data1',
data2 : 'data2'
}
},
methods:{
$_mixin1_method1(){
}
}
}
Parent.vue
import mixin1 from './mixin1';
export default {
name : 'Parent',
mixins:[mixin1],
data(){
return {
parent1 : 'parent1'
}
},
mounted(){
console.log(this.parent1); // parent1
console.log(this.$_mixin1_data1) //undefined
console.log(this.data2); //data2
}
}
When I use Parent component with mixin1 component, Parent component could not find data that starts with $. But "data2" data and the method that starts with $ is worked. I don't know why the data that starts with $_ isn't detected. I might not understand Vue's concept.
Thanks for your reply.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
docs
Docs