I am trying to use a plugin from GodofBrowser, as stated but I am getting an error
this.$dialog.confirm('Please confirm to continue')
Uncaught TypeError: Cannot read property 'confirm' of undefined
so this.$plugin is undefined .... why ?
// I installed it via npm
npm install vuejs-dialog
main.js
// I imported it
import Vue from "vue"
import VuejsDialog from "vuejs-dialog"
// and I told Vue to install it
Vue.use(VuejsDialog)
Then I am trying to use it in my App.vue, on 'click' method :
App.vue
<template>
<div id="app" class="container">
<ul class="navigation">
<li id="home"><router-link :to="{ name: 'Home' }" >Home</router-link></li>
<li id="shoppinglists" v-if="!logged">
<span @click.capture="clicked">
<router-link :to="{ name: 'ShoppingLists' }" >Shopping Lists</router-link>
</span>
</li>
<li v-else id="shoppinglists"><router-link :to="{ name: 'ShoppingLists', params: { id: currentUserId } }" >Shopping Lists</router-link></li>
</ul>
<router-view></router-view>
</div>
</template>
<script>
import store from '@/vuex/store'
import { mapGetters } from 'vuex'
export default {
name: 'app',
methods: {
clicked: (event) => {
event.preventDefault()
console.log('clicked!'). // got it in console
this.$dialog.confirm('Please confirm to continue') // !ERROR
.then(function () {
console.log('Clicked on proceed')
})
.catch(function () {
console.log('Clicked on cancel')
})
}
},
computed: {
...mapGetters({ currentUserId: 'getCurrentUserId', logged: 'getLogged' })
},
store
}
</script>