Skip to content

Error in beforeMount hook: "Error: Please provide a component #9

Description

@MmKargar

"xmodal-vue": "^0.2.0"

"vue": "^2.6.11"

thanks for this pakcage.
i want to run simple example but its give this error in console :
image

the component path is true , but when i remove .default from end of component path the error solve but when i click on the button , nothing happen.

this is my code like your example :
html:

    <div id="introduce">
        <button @click="isModalOpen = !isModalOpen">open</button>
        <xmodal v-model="isModalOpen" :params="options" />
    </div>

introduction.js:

import Vue from "vue";
import xmodal from "xmodal-vue";
Vue.use(xmodal);

const introduce = new Vue({
  el: "#introduce",
  data: {
    isModalOpen: false,
    options: {
      component: require("./modal.vue").default,
      backgroundColor: "#000000",
      opacity: "0.7",
      mounted: this.modalOpen,
      destroyed: this.modalClose,
    },
  },
  methods: {
    modalOpen() {
      console.log("modal is mounted");
    },
    modalClose() {
      console.log("modals closed");
    },
  },
});

and this is the modal.vue :

<template>
    <div class="modal">test modal</div>
</template>

<script>
export default {}
</script>

<style scoped>
.modal {
    width: 500px;
    height: 300px;
    background: white;
    border-radius: 15px;
}
</style>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions