Taro(V2.0.5)中引入Vant Weapp,(需下载资源到项目中:大小约322KB)
需如下几步:
1.在/src/components下新建文件夹vant-weapp
2.在github上找到Vant-weapp下载文件包,将对应的dist文件夹下内容复制到新建的vant-weapp文件夹下。
(下载vant-weapp方式,编辑器终端输入:git clone https://github.com/youzan/vant-weapp.git )
3.在Pages或components对应文件的config.usingComponents中,配置每个页面所需要的组件。(注:无法在app.js中进行全局注册组件。)
例:
config = {
usingComponents: {
"van-icon":"../../components/vant-weapp/icon/index"
}
}
4.在使用Vant-weapp组件后,taro会自动将相应的组件复制一份到dist/components下,而Vant-weapp的组件还依赖工具库/src/components/vant-weapp/wxs,该工具库taro不会自动复制到dist中。所以,我们需要在/config/index.js文件下的config配置中新增copy.patterns,让其在编译时,自动复制到dist对应目录下。
copy: {
patterns: [
{from:'src/components/vant-weapp/wxs/',to:'