小程序引入vant组件步骤详解及其问题
发布于 3 年前 作者 xiulan97 4975 次浏览 来自 分享

1、npm init 初始化

2、npm i vant-weapp -S --production

3、在工具里点击构建npm

4、在项目的本地设置里勾选使用npm模块

5、以按钮组件为例,在页面中引入注册(引入的路径视组件地址的相对位置引入)

{
  "usingComponents": {
    "van-button": "../../dist/button/index"
  }
}

6、接着在wxml里引入组件就可以使用了

<van-button type="primary">按钮</van-button>

7、引入后报错,重启一下开发者工具就好了。

回到顶部