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

feat: createApp support lifetimes hooks #10995

Closed
Simon-He95 opened this issue May 23, 2024 · 6 comments
Closed

feat: createApp support lifetimes hooks #10995

Simon-He95 opened this issue May 23, 2024 · 6 comments

Comments

@Simon-He95
Copy link
Contributor

Vue version

v3

Link to minimal reproduction

vue ceateApp api

Steps to reproduce

image

What is expected?

When we use createApp, I have no way of knowing when append is called on my element, because I may need to operate or obtain information at that time, in the upper layer, instead of defining onMounted in the App component.
I know that this modification of the parameters of the existing createApp may be a destructive change. If a new api is provided, such as createNewApp, it can be designed like this. Or there is a better design to make it easier to extend
image

What is actually happening?

createApp just accept props

System Info

No response

Any additional comments?

No response

@LinusBorg
Copy link
Member

import { creatApp, h } from 'vue'
import App from 'App.vue'

const app = createApp({
  onMounted() {
    // do what you need here
  },
  render: () =>  h(App)
})

@Simon-He95
Copy link
Contributor Author

Simon-He95 commented May 23, 2024

@LinusBorg,This is a solution I didn't expect, thanks, but I have one more question。
image

image

when mounted, mount(div), the div children don't have element

@LinusBorg
Copy link
Member

That would depend on the implementation of that component. Seems that it rendered nothing, maybe because of a v-if? I cant tell without seeing it

@Simon-He95
Copy link
Contributor Author

That would depend on the implementation of that component. Seems that it rendered nothing, maybe because of a v-if? I cant tell without seeing it这将取决于该组件的实现。似乎没有渲染任何内容,也许是因为 v-if?不亲眼所见我无法分辨

image

It’s pure html without any js logic.

@Simon-He95
Copy link
Contributor Author

I will give you a warehouse address later. Are you interested in helping track it down?

@LinusBorg
Copy link
Member

Have you checked that cur.component is actually containing the component at the moment of rendering?

@github-actions github-actions bot locked and limited conversation to collaborators Jun 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants