How to introduce plug-ins in vuejs

青灯夜游
Release: 2023-01-11 09:22:42
Original
3807 people have browsed it

Introduction method: 1. Use the import and "Vue.use(..)" statements in "main.js"; 2. Add the "import 'path" statement in the script tag of the vue file; 3. , use import and "components:{}" statements in "app.vue", etc.

How to introduce plug-ins in vuejs

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

The first step: install, download manually, customize the plug-in, visit the website address

For general vue or js plug-ins, you can usually install them directly, and then proceed. step. However, it is not ruled out that the installation fails for various reasons and requires manual downloading. There are also some custom plug-ins.

Step 2: Introduce the plug-in

js global introduction

main.js file addition

import Loading from './components/loading'
Vue.use(Loading)
Copy after login

js is introduced separately

Add in the vue file script tag

import '../../../components/loading/index.js'
Copy after login

vue is introduced globally

vue generally imports js It is introduced again, so the introduction method is the same as js. But there are special cases, such as the introduction of the navigation bar, which is directly introduced by vue, and globally,

import Header from './components/Header'
components: {
    Header
  }
Copy after login

vue is introduced separately in app.vue

is introduced separately Also add the above code

to directly introduce

1, add

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=?"></script>
Copy after login

2 to the index.html of the project, build/webpack.base.conf. In the js configuration file, set the external extension (externals attribute)

externals: {
    'BaiduMap': 'BMap'
}
Copy after login

Modular introduction

The same as js global introduction, this part requires that the plug-in can be installed or downloaded

Related recommendations: "vue.js Tutorial"

The above is the detailed content of How to introduce plug-ins in vuejs. 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