#小程序# mpvue引入vant的注意事项

#小程序# mpvue引入vant的注意事项

自学IT的攻城狮 2020-04-30 23:13:20 285 收藏
文章标签: 小程序 mpvue
版权
- 安装vant
- npm install vant-weapp -S --production
- 引用
- /app.json
"usingComponents": {
"van-button": "vant-weapp/dist/button/index"
}

- 使用
<template>
<div id="hello">
hello world!!! <van-button type="primary">click</van-button>
</div>
</template>

- webpack.base.config.js配置
- 作用: 在编译的时候在小程序中复制node_modules文件加下的vant-app/dist目录
if (/^wx$/.test(PLATFORM)) {
baseWebpackConfig = merge(baseWebpackConfig, {
plugins: [
new CopyWebpackPlugin([{
from: resolve('node_modules/vant-weapp/dist'),
to: resolve('dist/wx/vant-weapp/dist'),
ignore: ['.*']
}])
]
})
}

- 小程序项目配置
- 勾选 ES5 转成 ES6
- 一定要勾选, 否则运行会报错
————————————————
版权声明:本文为CSDN博主「自学IT的攻城狮」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_43753747/article/details/105871559

posted @ 2021-10-08 15:18  前端白雪  阅读(199)  评论(0编辑  收藏  举报