vue-final / vue-final-modal

🍕Vue Final Modal is a tiny, renderless, mobile-friendly, feature-rich modal component for Vue.js.
https://vue-final-modal.org
MIT License
864 stars 95 forks source link

does not provide an export named '$vfm' #365

Closed georginklv closed 7 months ago

georginklv commented 1 year ago

I am using Vue3, composition API with vite.
In main.ts am setting vue final modal like this

import { vfmPlugin } from 'vue-final-modal';
import './scss/main.scss';
import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap';

createApp(App)
  .use(vfmPlugin({
    key: '$vfm',
    componentName: 'VueFinalModal',
    dynamicContainerName: 'ModalsContainer'
  }))

and when i want to call the the modal from the component and i get this error which is says that $vfm is not provide in the modules

  <div>
    <AppButton :text="'Submit'" @click="submit()" />
  </div>
</template>

<script setup lang="ts">
  import AppButton from '../components/custom/buttons/AppButton.vue';
  import HistoryDialog from '../components/dialogs/HistoryDialog.vue'  
  import { $vfm } from 'vue-final-modal' 

  const submit = () => {
    $vfm.show(
      { component: HistoryDialog }, { type : 'Case' }d
    );
  };
</script>

Also i added import { ModalsContainer } from 'vue-final-modal' in App.vue

georginklv commented 1 year ago

https://stackoverflow.com/a/76170969/10607669 This solved my problem

hunterliu1003 commented 7 months ago

Duplicate with #404