当前位置:网站首页>按需引入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
边栏推荐
- Pep517 error during pycuda installation
- Unwind 栈回溯详解
- Emergency medical communication solution | mesh wireless ad hoc network system
- onnxruntime-gpu 1.7 出现的警告“Force fallback to CPU execution for node: Gather_191”等
- 通过sparksql读取presto中的数据存到clickhouse
- unhandled system error, NCCL version 2.7.8
- Systrace parsing
- Unable to determine the device handle for GPU 0000:02:00.0: GPU is lost.
- golang实现MD5,SHA256,bcrypt加密
- AUTOSAR从入门到精通100讲(五十一)-AUTOSAR网络管理
猜你喜欢
AUTOSAR从入门到精通100讲(八十一)-AUTOSAR基础篇之FiM
pth 转 onnx 时出现的 gather、unsqueeze 等算子
Urban emergency management - urban emergency communication command and dispatching system
AMBA协议学习小记
电力行业巡检对讲通信系统
主流 RTOS 评估
枫桥学院开元名庭酒店DMR系统解决方案
Draw margin curve in arcface
Gather, unsqueeze and other operators when PTH is converted to onnx
自定义classloader并实现热部署-使用loadClass
随机推荐
北峰油气田自组网无线通信对讲系统解决方案
记录阿里云服务器挖矿程序处理
EasyUI combobox determines whether the input item exists in the drop-down list
如何利用qemu搭建SOC protoype:80行代码实现一个Cortex M4 模拟器
美摄科技受邀LVSon2020大会 分享《AI合成虚拟人物的技术框架与挑战》
PyTorch 11. Regularization
PC端一次启动多个微信
Proteus 8.10安装问题(亲测稳定不闪退!)
Unable to determine the device handle for GPU 0000:02:00.0: GPU is lost.
基于openmv的无人机Apriltag动态追踪降落完整项目资料(labview+openmv+apriltag+正点原子四轴)
AUTOSAR从入门到精通100讲(八十七)-高级EEA的关键利器-AUTOSAR与DDS
“泉”力以赴·同“州”共济|北峰人一直在行动
Urban emergency management - urban emergency communication command and dispatching system
F.pad 的妙用
enforce fail at inline_ container. cc:222
golang实现一个带Web界面的五险一金计算器
以智能生产引领行业风潮!美摄智能视频生产平台亮相2021世界超高清视频产业发展大会
SQL练习第一题
免费开源智能充电桩物联网SAAS云平台
GIS实战应用案例100篇(五十二)-ArcGIS中用栅格裁剪栅格,如何保持行列数量一致并且对齐?