1

I need to use in function from javascript file in vue.js project,

I tried to add javascript file to script in component in my vue.js project and to get access to function but I did not succeed to add my javascript file in correct.

Nir Amir
  • 120
  • 1
  • 14
  • Does the script have an npm package? How exactly did you add it to your component? –  Sep 10 '19 at 15:24
  • 1
    Also: https://stackoverflow.com/questions/45047126/how-to-add-external-js-scripts-to-vuejs-components (dupe) –  Sep 10 '19 at 15:25
  • Welcome to SO! You'll need to edit your question to include a [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – technogeek1995 Sep 10 '19 at 15:47

1 Answers1

0

You can add the javascript file then export you function from that file

export const test = ()=> {

  console.log("foo")

}

then in your vue component you can just import your function

import {test} from "./path/your-file-name"
Aziz.G
  • 3,599
  • 2
  • 17
  • 35