Vue组件传值ref和props
ref
父组件获取子组件的属性和方法:<Son ref="son"></Son>
<script>
//获取ref为user的子组件的data值,属性为msg
let data = this.$refs.son.msg;
//调用ref为user的子组件的open方法
let method = this.$refs.son.open();
</script>data() {
return{
msg: 'hello lvjie'
}
},
methods:{
open(){
console.log('this is a open method')
}
}
props
父组件向子组件传值
<!-- |
<h1>子组件</h1> |
子组件向父组件传值
<h1>子组件</h1> |
<h1>父组件</h1> |
Vue组件传值ref和props
# 推荐文章
1.absolute和relative定位
2.display:table-cell在布局上的应用
3.两列布局css
4.解决GitHub访问不了问题
5.Collection集合和Map集合
6.JDK,JRE和JVM
1.absolute和relative定位
2.display:table-cell在布局上的应用
3.两列布局css
4.解决GitHub访问不了问题
5.Collection集合和Map集合
6.JDK,JRE和JVM







