- 安装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
- 一定要勾选, 否则运行会报错
#小程序# mpvue引入vant的注意事项
最新推荐文章于 2024-02-27 23:54:32 发布