Skip to content

Compound component with passing props #12955

Answered by pdsuwwz
LadIQe asked this question in Help/Questions

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

You must be logged in to vote
2 replies
@LadIQe

@jh-leong

You must be logged in to vote
7 replies
@LadIQe

@pdsuwwz

@LadIQe

@pdsuwwz

Answer selected by LadIQe
@LadIQe

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