当前位置:网站首页>按需引入vant组件
按需引入vant组件
2022-04-23 06:17:00 【ZMJ_QQ】
安装插件、添加配置
babel-plugin-import 是一款 babel 插件,它会在编译过程中将 import 的写法自动转换为按需引入的方式。
# 安装插件
npm i babel-plugin-import -D
// 在.babelrc 中添加配置
// 注意:webpack 1 无需设置 libraryDirectory
{
"plugins": [
["import", {
"libraryName": "vant",
"libraryDirectory": "es",
"style": true
}]
]
}
// 对于使用 babel7 的用户,可以在 babel.config.js 中配置
module.exports = {
plugins: [
['import', {
libraryName: 'vant',
libraryDirectory: 'es',
style: true
}, 'vant']
]
};
定义一个js文件
//按需引入vant-ui组件
import {Button,List} from 'vant';
const compontent = [Button,List]
export default function install(Vue) {
if (install.installed) return
compontent.forEach(i => Vue.component(i.name, i))
}
在main.js中注册
import vant from "./components/vantComponents";
Vue.use(vant);
注意:有可能Toast引入后无用,可以在页面 中再次引入。
版权声明
本文为[ZMJ_QQ]所创,转载请带上原文链接,感谢
https://blog.csdn.net/ZMJ_QQ/article/details/124001044
边栏推荐
- 防汛救灾应急通信系统
- Solution of self Networking Wireless Communication intercom system in Beifeng oil and gas field
- Cmder Chinese garbled code problem
- LPDDR4笔记
- 免费开源智能充电桩物联网SAAS云平台
- 使用 trt 的int8 量化和推断 onnx 模型
- F. The wonderful use of pad
- 如何利用qemu搭建SOC protoype:80行代码实现一个Cortex M4 模拟器
- SDC intelligent communication patrol management system of Nanfang investment building
- 基于51单片机的体脂检测系统设计(51+oled+hx711+us100)
猜你喜欢
随机推荐
Unable to determine the device handle for GPU 0000:02:00.0: GPU is lost.
RISCV MMU 概述
Systrace parsing
jvm知识点汇总-持续更新
go语言数组操作
JDBC连接池
Solution of self Networking Wireless Communication intercom system in Beifeng oil and gas field
golang实现正则匹配:密码包含至少一位数字,字母和特殊字符,且长度8-16
PyTorch 14. module类
Unable to determine the device handle for GPU 0000:02:00.0: GPU is lost.
Pep517 error during pycuda installation
FATFS FAT32学习小记
SPI NAND FLASH小结
美摄科技推出桌面端专业视频编辑解决方案——美映PC版
【无标题】制作一个0-99的计数器,P1.7接按键,P2接数码管段,共阳极数码管,P3.0,P3.1接数码管位码,每按一次键,数码管显示加一。请写出单片机的C51代码
go语言切片操作
学习资料
《Attention in Natural Language Processing》翻译
使用 trt 的int8 量化和推断 onnx 模型
pth 转 onnx 时出现的 gather、unsqueeze 等算子








