父组件rootA001
- ....
-
- provide() {
- //return {
- // this.refreshCurrentTab对应methods中的方法,无括号
- //refreshCurrentTab: this.refreshCurrentTab
- //}
-
- return {
- refreshCurrentTab: () => {
- return this.refreshCurrentTab()
- }
- }
- },
-
- methods: {
- refreshCurrentTab() {
- .....
- }
- .....
- }
- ......
任意子孙组件:
- ...
- inject: ['refreshCurrentTab'],
- methods:{
-
- getXXX(){
- ...
- },
-
- submitForm() {
- ....
- // 调用祖级组件rootA001的方法
- this.refreshCurrentTab()
- ......
- },
- ......
-
- }