Sometimes, we want to import functions from different JavaScript file in a Vue Webpack project.
In this article, we’ll look at how to import functions from different JavaScript file in a Vue Webpack project.
How to import functions from different JavaScript file in a Vue Webpack project?
To import functions from different JavaScript file in a Vue Webpack project, we use import
.
For instance, we write
<script>
import test from "@/mylib";
console.log(test.foo());
//...
</script>
to import the mylib
module’s default export as test
.
Then we call the test.foo
method.
@
is the alias for the src folder in the Vue project.
Conclusion
To import functions from different JavaScript file in a Vue Webpack project, we use import
.