Skip to content

Compound component with passing props #12955

Answered by pdsuwwz
LadIQe asked this question in Help/Questions
Discussion options

You must be logged in to vote

@LadIQe Thanks for providing the repo, I have roughly read the code.

I have written a demo Playground for your reference.

It should be noted that you should not put the render function (createElement) directly into the normal function. You need to use the defineComponent to define the local component, otherwise it will cause re-rendering every time you input, which will cause the input to lose focus automatically:

const createElement = defineComponent({
  render() {
    const slotContent = slots.default?.()?.[0]
    if (!slotContent) return null

    const _props = mergeProps(
      {
        ...props,
        ...attrs,
          value: modelValue.value,
          onInput(event) {

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
2 replies
@LadIQe
Comment options

@jh-leong
Comment options

Comment options

You must be logged in to vote
7 replies
@LadIQe
Comment options

@pdsuwwz
Comment options

@LadIQe
Comment options

@pdsuwwz
Comment options

Answer selected by LadIQe
@LadIQe
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants