Skip to content

Conversation

Mini-ghost
Copy link
Collaborator

In current, useModal usage like following code:

<script setup lang="ts">
import { markRaw } from 'vue'
import { VueFinalModal, useModal } from 'vue-final-modal'

const modalInstance = useModal({
  component: markRaw(VueFinalModal),
  slots: {
    // pass a html string
    default: '<p>The content of the modal</p>',

    // pass a object include `component` and optional `attrs`
    default: {
      component: markRaw(CustomComponent),
      attrs: {
        // <CustomComponent />'s  props
      }
    }
  }
})
</script>

This PR improves two features:

  1. Users no longer need to use markRaw to wrapper component.
  2. slots allow passing slot name and components directly.

The following code is new usage after this PR

<script setup lang="ts">
import { markRaw } from 'vue'
import { VueFinalModal, useModal } from 'vue-final-modal'

const modalInstance = useModal({
  component: VueFinalModal,
  slots: {
    // pass a html string
    default: '<p>The content of the modal</p>',

    // pass a object include `component` and optional `attrs`
    default: {
      component: CustomComponent,
      attrs: {
        // <CustomComponent />'s  props
      }
    },

    // pass a component directly
    default: CustomComponent,
  }
})
</script>

@hunterliu1003 hunterliu1003 merged commit 7096354 into v4 Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants