maoruibin / maoruibin/maoruibin.github.com

Vue 父组件调用子组件方法

Open
#69 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
22
Forks
4
PR merge metrics
No merged PRs in 30d

Description

组件关系
app.vue

<el-main >
		<Container
			v-show="!dashboard"
			:user="user"
			@showTodoDetail="showTodoDetail"/>

		<Dashboard
			v-show="dashboard"/>
</el-main>

showDashboard:function(){
	//			
}

其中包含子组件 Dashboard
现在需要在 showDashboard 方法中调用到 Dashboard 的方法 refresh

dashboard.vue

    methods: {

      refresh:function(){
      console.log("---------------")
      },

只需要在组件声明处 定义好 ref 对象,

<Dashboard
    v-show="dashboard"
    ref="dashboard"/>

然后

showDashboard:function(){
     this.$refs.dashboard.refresh()		
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names app.vue and dashboard.vue and shows showDashboard, Dashboard, and refresh as entry points. Start by locating the corresponding content in the blog repository; no target file, test, or acceptance criteria is provided, so the definition of done cannot be determined from the issue alone.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, javascript
Domain
documentation, frontend
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.