$children 指代的是子组件,返回的是一个组件集合

用法:

this.$children

如果你能清楚的知道子组件的顺序,你也可以使用下标来操作;

var inputDom = this.$children[0].$el.querySelectorAll(".el-input__inner")[0];
 
$parent  指代的是父组件 ,返回的是一个组件集合
用法:
this.$parent
this.$parent[0]
 

注意:

1)组件只能有一个根节点

2)可以在子组件中使用this.$parent.属性值,或者函数

3)在父组件中可以使用this.$refs.组件的标记 访问子组件,或者this.$children[i].属性

 4)你需要注意this的指向

相关文章:

  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
猜你喜欢
  • 2022-12-23
  • 2021-12-24
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案