Vue error: Injection "xxxx" not found

1. Cause

When subcomponents or grandchildren inject dependencies provided by the parent component provide, subcomponents or grandchildren are introduced on different pages. Some pages use provide to provide dependencies, and some pages will report errors if they do not provide dependencies.

2. Solutions

API in vue2's docs — Vue.js

You can use the default downgrade of the object method

 write in general

inject:['getTable','getUser']

changed to

 inject: {
    getTable: { value: "getTable", default: null },
    getUser: { value: "getUser", default: null },
  }

can be solved

Guess you like

Origin blog.csdn.net/future_1_/article/details/129585823