Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
Access this.<module> from within Nuxt plugin

Is there any way I can access a JS API exposed by a Nuxt module from within a client-side plugin?

Context: I'm using Buefy/Bulma, which is loaded like this in nuxt.config.js:

modules: [
    ['nuxt-buefy', {css: false}],
],

Buefy exposes this.$buefy.<etc> which is accessible from components.

But I want to access this API from within a client-side plugin, utils.js, which is loaded like this:

plugins: ['~/plugins/utils.js'],

And utils.js itself:

export default ({app}, inject) => {
    inject('myUtil', (msg, isErr) => {
        app.$buefy; //<-- undefined
        ....

I assume this is an ordering issue, i.e. Buefy is being loaded after my plugin or something. I can't do this in a static JS file loaded via meta.scripts as that won't have access to the app (I assume).

Anything I can do here?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try this in your plugin js file

import { ToastProgrammatic as toast } from 'buefy';

export default (_, inject) => {
  inject('appHelper', {
    displayToast(duration = null, msg = null, position = null, type = null) {
      toast.open({
        duration: duration || 3000,
        message: msg || 'Update Successful',
        position: position || 'is-bottom-left',
        type: type || 'is-success',
      });
    },
  });
};
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda