mpvue做微信小程序的一些坑坑~

2018-11-21  本文已影响0人  游荡的猫咪

iview插件的引入

用微信小程序后,以前的第三方插件因为样式的问题而无法使用,而小程序有个weapp-iview,使用方法如下:

上拉加载下拉刷新

可以利用小程序的上拉刷新,下拉加载功能,具体用法如下:

全局变量的配置

可以把全局变量写在单独的js中export出来,然后在main.js中引用,并定义Vue.prototype.baseUrl(例如)。

轮播图

可以用小程序的轮播,用小程序的参数,vue的语法,例如:


    <swiper class="swiper swiper-container" 
            :indicator-dots="true" 
            interval="5000" 
            duration="1000" 
            autoplay>
      <block v-for="(item, index) in banners" :index="index" :key="index">
          <swiper-item>
              <img :src="item.src" class="swiper-slide" />
          </swiper-item>
      </block>
    </swiper>

footer vs tabbar

小程序有自己的tabbar,只需要在app.json里进行配置就好,无需自己写footer组件,配置如下:

"tabBar": {
    "list": [
      {
        "pagePath": "pages/index/main",
        "text": "tab1",
        "selectedIconPath": "./static/icon-1-current.png",
        "iconPath": "./static/icon-1.png"
      },
      {
        "pagePath": "pages/product/main",
        "text": "tab2",
        "selectedIconPath": "./static/icon-2-current.png",
        "iconPath": "./static/icon-2.png"
      },
      {
        "pagePath": "pages/index/main",
        "text": "tab3",
        "selectedIconPath": "./static/icon-3-current.png",
        "iconPath": "./static/icon-3.png"
      },
      {
        "pagePath": "pages/index/main",
        "text": "tab4",
        "selectedIconPath": "./static/icon-4-current.png",
        "iconPath": "./static/icon-4.png"
      },
      {
        "pagePath": "pages/pcenter/main",
        "text": "tab5",
        "selectedIconPath": "./static/icon-5-current.png",
        "iconPath": "./static/icon-5.png"
      }
    ],
    "color": "#666666",
    "selectedColor": "#e02e24",
    "backgroundColor": "#ffffff"
  }
上一篇 下一篇

猜你喜欢

热点阅读