vue 子组件获取父组件的属性、方法 和 父组件获取子组件的属性、方法

vue 子组件获取父组件的方法

this.$emit("searchhide");

vue 子组件获取父组件的数据

父组件

<child :trust-plan-id-list="data"></child>
  • 在子组件中声明并使用变量
    在props 中声明,然后就可以直接使用啦
 props:[
      "trustPlanIdList"
    ],

获取父组件的方法:

this.$parent.methods

获取父组件的属性:

this.$parent.options

 父组件获取子组件的方法

<search ref="search" v-show="!blurBgShow" @searchshow="rankshow=false" @searchhide="rankshow=true"></search>

获取子组件的属性:

this.$refs.search.searchShow 

发布了29 篇原创文章 · 获赞 5 · 访问量 7984

猜你喜欢

转载自blog.csdn.net/qq_25194685/article/details/104752748