编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

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

wxchong 2024-08-26 23:48:57 开源技术 24 ℃ 0 评论
- 安装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
	- 一定要勾选, 否则运行会报错

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表