2

mpvue+vant 开发微信小程序

mpvue使用

# 全局安装 vue-cli
$ npm install --global vue-cli

# 创建一个基于 mpvue-quickstart 模板的新项目
$ vue init mpvue/mpvue-quickstart my-project

# 安装依赖
$ cd my-project
$ npm install
# 启动构建
$ npm run dev

vant使用

yarn add vant

# 将node_modules下的vant-weapp下的dist目录复制到static下的vant目录即可调用

vant调用

  1. main.json中调用
{
  "navigationBarTitleText": "Home",
  "usingComponents": {
    "van-button": "../../static/vant/button/index",
    "van-search": "../../static/vant/search/index",
    "van-tabbar": "../../static/vant/tabbar/index",
    "van-tabbar-item": "../../static/vant/tabbar-item/index",
  }
}
  1. index.vue中使用
<van-search
  placeholder="请输入搜索关键词"
  use-action-slot
  bind:search="onSearch"
  >
  <view slot="action" bind:tap="onSearch">搜索</view>
</van-search>

关注我的微信公众账号,分享更多~

微信公众账号


hirCodd
26 声望0 粉丝