Element: this.$notify is not a function

Created on 12 Mar 2017  ·  3Comments  ·  Source: ElemeFE/element

Weird thing about it is, it started to crash like this suddenly.

TypeError: this.$notify is not a function

I load Notification on demand like import { Notification } from 'element-ui' and then add it as a component

components: { Notification },
created () {
   this.$notify({ ... });
}

Version:

Build system: Laravel-mix

Most helpful comment

Should have read more carefully the docs, in my approach it wasn't needed to add it as a component, I could simply do something like Notification.success(options)

All 3 comments

Should have read more carefully the docs, in my approach it wasn't needed to add it as a component, I could simply do something like Notification.success(options)

add the folloing code after import { Notification } from 'element-ui'
Vue.prototype.$notify = Notification;

This thread helped me. Thanks.

<script>
    import { Notification } from 'element-ui';

    export default {
        name: "blah",
        data() {
            return { }
        },
        methods: {
           notify: function () {
                   Notification.success({title: "hello", message: "world", type: "success"});
           }
        },
        computed: {
          this.notify();
        },
Was this page helpful?
0 / 5 - 0 ratings