nuxt-community / legacy-modules

MIT License
1.28k stars 158 forks source link

@nuxtjs/toast - How to pass options to globally configured toast module #357

Open racode246 opened 4 years ago

racode246 commented 4 years ago

How to pass options to globally configured toast module? I could pass the message but not the options.

In my nuxt file I have:

  toast: {
    position: 'top-center',
    register: [
      {
        name: 'error',
        message: (payload: any) => payload.message,
        options: {
          type: 'error',
          icon: 'error',
          className: 'toastCustom--error',
          position: (payload: any) =>
            payload.position ? payload.position : 'top-center',
          duration: 5000
        }
      }
    ]
  }

and passed the option like this

this.$toast.global.error({ message: 'test' }, { position: 'bottom-center' })

What should I do?

marcosdipaolo commented 4 years ago

Anther question would be how to set globally a duration for both registered and non-registered toasts

andrewbartz commented 3 years ago

Has anyone figured this out?

TArch64 commented 2 years ago

Passing options via modules sections works fine

    modules: [
        ['@nuxtjs/toast', { duration: 5000 }]
    ],