nandi95 / vue-toastify

🔥 Simple, extendable, dependency free notification plugin. 🔥

Home Page:https://vue-toastify.netlify.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in mounted hook: "TypeError: Cannot read property '$on' of undefined"

bedus-creation opened this issue · comments

Error in mounted hook: "TypeError: Cannot read property '$on' of undefined"

Solved

I was not using eventBus which causes problem. Solved for laravel projects,

// app.js
window.EventBus = new Vue();;
window.flash = function (message, type) {
    let statusObject={
        title: type+ " !!!",
        type:type,
        body: message,
        defaultTitle: true
    }
    EventBus.$emit('vtNotify', statusObject);
};

// vue-error.blade.php

@if(Session::has('success'))
<script>
    window.flash("{{session('success')}}", "success");

</script>
@endif

@if(Session::has('error'))
<script>
    window.flash("{{session('error')}}", "error");

</script>
@endif
@foreach($errors->all() as $error)
<script>
    window.flash("{{$error}}", "error");
</script>

@endforeach

Bug In new Version 1.8.0

The above code used to work perfect with version 0.4.5. Now got new error.
Template or render function not defined.

My template file is

<div id="app">
      <vue-toastify></vue-toastify>
</div>

Since 0.4.5 there has been a major version change with breaking changes.

I advise you to read the updated documentation and update your logic inline with the new methods or only allow minor changes for this package in your packages.json