Subscribe on changes!

if vue3 plugin lib use provide/inject api and project use this plugin, error with inject does not get a value when plugin's vue version is different from the project's vue version

avatar
Aug 25th 2021

Version

3.2.6

Reproduction link

https://github.com/a1067111756/vue-verify/tree/master/element-form-verify-next

Steps to reproduce

/* plugin lib code */ // install plugin const install: any = function (app: App, options: VERIFY_TYPE.IGlobalOption) { app.provide('elFormItemVerifyGlobalOption', options) // provide a value app.component(ElFormItemVerify.name, ElFormItemVerify) // register component };

export default { install };


// ElFormItemVerify.vue import { defineComponent, inject} from 'vue'; export default defineComponent({ setup (props, context) { // inject a value const globalOption: VERIFY_TYPE.IGlobalOption = inject('elFormItemVerifyGlobalOption') as VERIFY_TYPE.IGlobalOption } })


/* some problems */ // situation 1 - when plugin's vue version is same as the project's vue version inject('elFormItemVerifyGlobalOption') as VERIFY_TYPE.IGlobalOption can get a correct value

// situation 2 - when plugin's vue version is different from the project's vue version inject('elFormItemVerifyGlobalOption') as VERIFY_TYPE.IGlobalOption get null

I don't know if my usage method is wrong, I hope to get an answer, Why does the inconsistency of the project's vue version and the plugin's vue version lead to different values ​​obtained by inject?

What is expected?

inject can get a correct value when plugin's vue version is different from the project's vue version

What is actually happening?

inject get null when plugin's vue version is different from the project's vue version

avatar
Aug 25th 2021

Hi, thanks for your interest but Github issues are for bug reports and feature requests only. You can ask questions on the forum, the Discord server or StackOverflow.