[Vuejs]-Show modal on Vue

0👍

this works for me in a vue-cli simple environment
and its works fine, tested

main.js

import App from "./App.vue";
import Vue from "vue";
import VModal from "vue-js-modal";

Vue.use(VModal);

Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div id="app">
    <h3>Hello world test</h3>
    <modal name="hello-world">
      hello, world!
    </modal>
    <button @click="showModal">show modal</button>
  </div>
</template>
<script>
export default {
  methods: {
    showModal() {
      this.$modal.show("hello-world");
    }
  }
};
</script>

<style lang="scss">
</style>

Leave a comment