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

605
Visualizações
Import Native JavaScript file into Vue Component - Vue Js

I have created frontend application with Vue Js. I want to integrate one native javascript file into the Vue component.

The native js file contains multiple util functions. I want to call those functions from my Vue component.

Native js file util.js

var helper = function(t) {
                var u = 'product',
                    A = 'version',
                return {
                    buildHelpUrl: function(a, b, c) {
                                   return "http://"
                                 }
               /* Snippets */
             }

I tried following way to import in my native js file into .vue file

Case 1: import OTHHUrlBuilder from '@/util.js';
Case 2: import * as urlbulider from '@/util.js';

Nothing worked. Please help me to properly import and use the functions available in the native js files.

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

0

First export all your functions you need to your .vue file.

Exemple on your .js file :

  const funcAdd = (a, b) =>  {
   return (a + b)
  }

  const funcSub = (a, b) =>  {
    return (a - b)
  }

  export { funcAdd , funcSub }

And then on your .vue file you can import all the exported functions.

On your .vue file :

  <script>

  import { funcAdd , funcSub } from '@/util.js'

 ...

If you have only one function function, you can use export default

On your .js file

const helper = (t) => {
          var u = 'product',
                    A = 'version',
                return {
                    buildHelpUrl: function(a, b, c) {
                                   return "http://"
                                 }
               /* Snippets */
             }

    export default helper

and on your .vue file

    import helper from '@/util.js'

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