Home > Article > Web Front-end > Introducing external js method instances into vue
When we are working on vue projects, we often need to introduce js. The following are commonly used. This article mainly shares with you examples of introducing external js methods into vue, hoping to help everyone.
The first one
import XX from “路径” Vue.use(XX); 这里的js文件要导出 用export default { Vue.proprtypes.aa=function(){} }
The second one
js file does not use export default{}
It’s just a pure method
Solution : You can add the following code to main.js, and the methods in it can be used globally.
require ('path')
The third method
is also a pure method
At the end, use export default {} for the method you want to use. Export
This method is used in a single Vue file, introduce your method through import {xxx} from 'path'
When using it, just call xxx.
When we are working on vue projects, we often need to introduce js. The following are commonly used.
The first one
import XX from “路径” Vue.use(XX); 这里的js文件要导出 用export default { Vue.proprtypes.aa=function(){} }
The second one
js file does not use export default{}
It’s just a pure method
Solution : You can add the following code to main.js, and the methods in it can be used globally.
require ('path')
The third method
is also a pure method
At the end, use export default {} for the method you want to use. Export
This method is used in a single Vue file, introduce your method through import {xxx} from 'path'
When using it, just call xxx.
Related recommendations:
How does the JS loader dynamically load external js files
Introduce external js files into html and call the Methods of parameterizing functions
Referring to external js garbled problem analysis and solutions_javascript skills
The above is the detailed content of Introducing external js method instances into vue. For more information, please follow other related articles on the PHP Chinese website!