Ich versuche, ein Plugin von GodofBrowser zu verwenden, wie gesagt, aber ich erhalte eine FehlermeldungVue.js Plugin-Fehler: undefined
this.$dialog.confirm('Please confirm to continue')
Uncaught TypeError: Cannot read property 'confirm' of undefined
so das $ Plugin nicht definiert ist .... warum.?
// 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)
Dann versuche ich es in meinem App.vue zu verwenden, auf 'Klick' Methode:
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>
Sie haben nicht VuejsDialog in der letzten Code Demo –
Mögliche Duplikat importiert [VueJS: Warum ist "das" nicht definiert?] (Https://stackoverflow.com/questions/43929650/vuejs-why-is- this-undefined) – thanksd
Ist es in der 'package.json' als Abhängigkeit definiert? –