Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

createApp passing props causes residual properties on html #12841

Answered by tsebim
tsebim asked this question in Help/Questions
Discussion options

createApp passed props Why does it have residual properties on html that look ugly,But the properties in Figure 2 are not left behind, and not because I passed a function, as I would if I tried to pass other properties.
image
image

You must be logged in to vote
tsebim收到来信

Replies: 6 comments

Comment options

But if I configure inheritAttrs to false, it's ok. It feels a little weird. Can anyone tell me why

You must be logged in to vote
0 replies
Comment options

The 'props' attribute passed into createApp is similar to the props object passed to h. It contains a mixture of component props, event listeners and fallthrough attributes.

That object is split up inside the component. Typically, you'd use defineProps to declare any props that your component uses. You don't currently seem to be doing that.

Any properties that aren't declared as component props or events become fallthrough attributes. These are what you get from useAttrs(). Fallthrough attributes are automatically applied to the root node of a component, which is why you see them as attributes of the <div> in the final DOM.

Fallthrough attributes are documented at https://vuejs.org/guide/components/attrs.html.

You should probably be using component props rather than fallthrough attributes. I can see why using attrs is convenient for your use case, but you're not really using it for its intended purpose.

You must be logged in to vote
0 replies
Comment options

tsebim收到来信
You must be logged in to vote
0 replies
Answer selected by tsebim
Comment options

tsebim收到来信
You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /