mpvue+vant前端开发

Finen 2019-02-26 1000000

# 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
1
2
3
4
5
6
7
8
9
10
11

# vant使用

yarn add vant

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

# 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
2
3
4
5
6
7
8
9
  1. index.vue中使用
<van-search
  placeholder="请输入搜索关键词"
  use-action-slot
  bind:search="onSearch"
  >
  <view slot="action" bind:tap="onSearch">搜索</view>
</van-search>
1
2
3
4
5
6
7