Home > Web Front-end > JS Tutorial > Introducing external js method instances into vue

Introducing external js method instances into vue

小云云
Release: 2018-03-02 11:24:24
Original
7261 people have browsed it

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(){}
}
Copy after login
Copy after login

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(){}
}
Copy after login
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template