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.
The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.
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.
js global introduction
main.js file addition
import Loading from './components/loading' Vue.use(Loading)
js is introduced separately
Add in the vue file script tag
import '../../../components/loading/index.js'
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 }
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>
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' }
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!