目前想在项目中按需引入vant组件,根据官网提示进行安装后可使用,但是目前的按需引入是每个组件
<template>
<div id="app">
<van-button type="warning">默认按钮</van-button>
</div>
</template>
<script>
import { Button } from 'vant';
Vue.use(Button);
export default {
name: 'index',
}
</script>
<style>
</style>
比如我整个项目中只需要vant组件中的一部分,这样在每个组件里面我都需要去写类似这样的引入
import { Button } from 'vant';
Vue.use(Button);
我打算把这些需要用到的组件整理到一个js文件中去,比如components.js,
import Vue from 'vue'
import {
Button,
} from 'vant'
Vue.use(Button)
我该怎么把这个js注入到项目中去,不必在每个页面单独引入了,在js中配置一下就可以了,
也就是nuxt.js这种写法 https://zh.nuxtjs.org/api/con...
我应该怎么引入
你既然都整理好了 直接在
main.js
把components.js
给import
进来就行