Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use in Nuxt.js #15

Open
mcmyth opened this issue Oct 17, 2020 · 3 comments
Open

How to use in Nuxt.js #15

mcmyth opened this issue Oct 17, 2020 · 3 comments

Comments

@mcmyth
Copy link

mcmyth commented Oct 17, 2020

// plugins/noty.js
import Vue from 'vue'
import 'vuejs-noty/dist/vuejs-noty.css'
const VueNoty = require('vuejs-noty')

Vue.use(VueNoty, {
  timeout: 3000,
  progressBar: true,
  layout: 'topRight'
})
// nuxt.config.js
// If set ssr to true, it will the throw error 'document is not defined'
plugins: [
    { src: '@/plugins/noty.js', ssr: false },
  ]
<script>
// index.vue
export default {
  mounted () {
    console.log(this.$noty)
  }
}
</script>

$noty is undefined
$noty doesn't seem to be added to the Vue prototype, what should I do?

@ErriourMe
Copy link

The same question but I want use it in plugin (for axios interceptors).

@tallcoder
Copy link

Same question, haven't been able to get it to work. If I do, I'll post how.

@JonathanSchndr
Copy link

JonathanSchndr commented Mar 1, 2022

late but maybe it helps someone else

// plugins/noty.js
import 'vuejs-noty/dist/vuejs-noty.css'
import Vue from 'vue'
import VueNoty from 'vuejs-noty'

export default ({app}, inject) => {
  inject('noty', Vue.use(VueNoty, {
    timeout: 3000,
    progressBar: false,
    layout: 'topRight',
    closeWith: ['click', 'button'],
  }).noty)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants