AStaroverov / vue-toast

toasts for vuejs
148 stars 28 forks source link

Vue 2 Laravel 5.3 Cannot read property 'showToast' of undefined #11

Closed warmjaijai closed 7 years ago

warmjaijai commented 7 years ago

Followed how the instruction does but not working, please help

.vue

<template>
    <div>
    <vue-toast ref='toast'></vue-toast>
    </div>
</template>

<script>
  import VueToast from 'vue-toast';
  export default {
    components:{
      'vue-toast': VueToast,
    },
    created(){
      const toast = this.$refs.toast

      toast.showToast('Show me toast')
      toast.showToast('Show me toast again!')
    },
......
......

ERROR (console log):

TypeError: Cannot read property 'showToast' of undefined at VueComponent.created (eval at (app.js:327), :39:10) at callHook (eval at (app.js:125), :2610:19) at VueComponent.Vue._init (eval at (app.js:125), :3364:5) at new VueComponent (eval at (app.js:125), :3483:12) at createComponentInstanceForVnode (eval at (app.js:125), :2761:10) at init (eval at (app.js:125), :2771:31) at createComponent (eval at (app.js:125), :4120:9) at createElm (eval at (app.js:125), :4063:9) at createChildren (eval at (app.js:125), :4171:9) at createElm (eval at (app.js:125), :4096:9) logError

AStaroverov commented 7 years ago

Try use mounted hook lifecycle instead created

чт, 9 февр. 2017 г., 6:13 warmjaijai notifications@github.com:

Please help

.vue

Githubissues.
  • Githubissues is a development platform for aggregating issues.