Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/inject not work between parent and child component in vue3 #35

Open
imhuntun opened this issue Oct 7, 2023 · 4 comments
Open
Assignees
Labels
acknowledged Acknowledged

Comments

@imhuntun
Copy link

imhuntun commented Oct 7, 2023

Describe the bug
I pass in a component by templete, and the data provided by the outermost component cannot be read by inject in the child component.

in parent component:
provide('setting', {a:1,b:1});

in child component:
const setting = inject('setting'); // get nothing

@motla
Copy link
Owner

motla commented Oct 9, 2023

Hi! Thanks for your interest on the library. Can you share a minimal example showing your issue so I can debug it? (the easiest way is to fork this project on github, make modifications and rebuild it).

Another way to pass data to template components is to use modelValue property as shown in the demo (docs here, example here and here)

@imhuntun
Copy link
Author

After version 2.1, you adjusted the component loading mode to load the component as a customElement, causing the loaded component file name to have to end with ce.vue. In more complex component nesting, the component styles after the second layer cannot be loaded properly.

I wonder if my use method is wrong? If there is a correct method, I hope to give examples.

Finally, thank you very much for your effort, this component is very useful.

My component structure is shown below.
未命名文件(15)

@motla
Copy link
Owner

motla commented Oct 10, 2023

Thanks for the clear explanation.
Indeed I had to use a customElement, otherwise conflicts happened between Vue3 and the contenteditable DOM.
Maybe I could try to improve this in the future (manage templates differently) but it seems not an easy task...
I don't like the .ce.vue system either so I leave this issue open as a reminder.

If you still can't get your project working I can take a look at it to help you.

@motla motla self-assigned this Oct 10, 2023
@motla motla added the acknowledged Acknowledged label Oct 10, 2023
@imhuntun
Copy link
Author

Thank you for your answer, then I have to continue to use version 2.0.7, my program can be used normally on this version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acknowledged Acknowledged
Projects
None yet
Development

No branches or pull requests

2 participants