Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Modal $vfm not working Vue3 #448

Open
odion-cloud opened this issue Aug 2, 2024 · 0 comments
Open

Dynamic Modal $vfm not working Vue3 #448

odion-cloud opened this issue Aug 2, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@odion-cloud
Copy link

Version
vue-final-modal: ^3.4.6
vue: ^3.4.34

windows 10

Steps to reproduce
my code in vfmplugin.js

import { vfmPlugin } from 'vue-final-modal';

// Export the plugin directly for use in `app.js`
export { vfmPlugin };

my app.js

import { createApp } from 'vue';
import App from './views/layouts/Layout.vue';
import router from './libs/router';
import { vfmPlugin } from './libs/vfmplugin'; // Import vfmPlugin
import {openModal,closeModal} from './function/openModal'

const app = createApp(App);
// Global mixin helpers
app.mixin({
  methods: {
    openModal: openModal,
    closeModal: closeModal,
  },
});

app.use(router);
app.use(vfmPlugin); 
// Mount to the <app> element
app.mount('app');

my code in openModal.js

import { $vfm } from 'vue-final-modal';
export const openModal = (cname,param) => {

  const com = () => import(`../views/viewmyntebot/pages/others/${cname}.vue`) 
    $vfm.show({component: com,
    bind: {
        params: param
      }},param)
}

export const closeModal = (name) => {
  if(name) {
    $vfm.hide(name)
  }else {
    $vfm.hideAll()
  }
}

my Layout.vue

<template>
 <div class="main">
    <div class="main-container sub-container-bg">
     <main class="body-container">
       <router-view></router-view>
     </main>
     <modals-container style="position: fixed;z-index:100;"></modals-container>
     
    </div>
  </div>

  </template>

my code in pages/partials/playlist/Index.vue

<template>
    <vue-final-modal name="playlistHome" v-slot="{ close }" v-bind="$attrs" v-on="$listeners" :hide-overlay="true">

        <div class="modal" tabindex="-1">
            <div class="modal-dialog">
              <div class="modal-content">
                <div class="modal-header">
                  <h5 class="modal-title">Modal title</h5>
                  <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                  <p>Modal body text goes here.</p>
                </div>
                <div class="modal-footer">
                  <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                  <button type="button" class="btn btn-primary">Save changes</button>
                </div>
              </div>
            </div>
          </div>
    </vue-final-modal>
  </template>

when i click @click="openModal('partials/playlist/Index')" it returns

app.js:8254 [Vue warn]: Invalid VNode type: undefined (undefined) 
  at <Com key= Symbol(dynamicModal) params=undefined modelValue=true  ... > 
  at <ModalsContainer style= {position: 'fixed', z-index: '100'} > 
  at <Layout>

What is Expected?
No warnings and modal is shown

@odion-cloud odion-cloud added the bug Something isn't working label Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants