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調用
- 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",
}
}
- index.vue中使用
<van-search
placeholder="請輸入搜索關鍵詞"
use-action-slot
bind:search="onSearch"
>
<view slot="action" bind:tap="onSearch">搜索</view>
</van-search>
關注個人微信公衆帳號,分享更多~