12

I am trying to fire a simple notification in Quasar 2:

setup() {
  const $q = useQuasar()
   $q.notify('hello')
}

This fails with:

Uncaught TypeError: $q.notify is not a function

This is a UMD application that works fine without these two lines - I do not really know where to go from there as the docs say that there is nothing special to configure before using it.

Incindentally, my IDE is suggesting me notify() when typing $q. so at least at that level is it well recognized.

WoJ
  • 27,165
  • 48
  • 180
  • 345

3 Answers3

17

I think you forgot to add notify in plugins(quasar.conf.js).

return {
  framework: {
    plugins: [
      'Notify'
    ],
  }
}
Pratik Patel
  • 5,995
  • 1
  • 18
  • 39
6

For those using Vue CLI, you will need to work on quasar-user-options.js:

import { Notify } from "quasar";

// To be used on app.use(Quasar, { ... })
export default {
   plugins: { Notify },
};
ARNON
  • 1,097
  • 1
  • 15
  • 33
1

Quasar vite plugin + vue3

In main.ts or main.js, just add these 2 lines :

JS
import { Notify } from "quasar";
.use(Quasar, {
    plugins: {
        Notify,
    }, // import Quasar plugins and add here
})

Here a example of my code :

JS
import { createApp } from 'vue'

import { Quasar } from 'quasar'
import quasarLang from 'quasar/lang/fr'
import { Notify } from "quasar";
import router from './router'
import { createPinia } from 'pinia'
import './style.css'


// Import icon libraries
import '@quasar/extras/material-icons/material-icons.css'

// Import Quasar css
import 'quasar/src/css/index.sass'

import App from './App.vue'

const pinia = createPinia()

createApp(App)
.use(Quasar, {
    plugins: {
        Notify,
    }, // import Quasar plugins and add here
    lang: quasarLang,
})
.use(router)
.use(pinia)
.mount('#app')
Joh
  • 11
  • 2