微信小程序 MinUI 組件庫系列之 loadmore 頁底組件

MinUI 是基於微信小程序自定義組件特性開發而成的一套簡潔、易用、高效的組件庫,適用場景廣,覆蓋小程序原生框架、各類小程序組件主流框架等,而且提供了高效的命令行工具。MinUI 組件庫包含了不少基礎的組件,其中 loadmore 頁底組件是一個很經常使用的基礎元件, MinUI 中 loadmore 組件的效果圖以下:javascript

loadmore

各式各樣的類型都有哦,是否是看起來很方便很快捷的樣子(^_^)。能夠打開微信掃一掃下面的小程序二維碼先一睹爲快:html

loadmore

下面介紹 loadmore 組件的使用方式。前端

一、使用下列命令安裝 Min-Cli,如已安裝,請進入到下一步。Min-Cli 的文檔請猛戳這裏:Min-Cli使用手冊java

npm install -g @mindev/min-cli

二、初始化一個小程序項目。git

min init my-project

選擇 新建小程序 選項,便可初始化一個小程序項目。建立項目後,在編輯器中打開項目,src 目錄爲源碼目錄,dist 目錄爲編譯後用於在微信開發者工具中指定的目錄。新建的項目中已有一個 home 頁面。詳細文檔:Min 初始化小程序項目github

三、安裝 loadmore 組件。npm

進入剛纔新建的小程序項目的目錄中:小程序

cd my-project

安裝組件:微信小程序

min install @minui/wxc-loadmore

四、開啓dev。bash

min dev

開啓以後,修改源碼後都會從新編譯。

五、在頁面中引入組件。

在編輯器中打開 src/pages 目錄下的 home/index.wxp 文件,在 script 中添加 config 字段,配置小程序自定義組件字段,代碼以下:

export default {
    config: {
        "usingComponents": {
            'wxc-loadmore': "@minui/wxc-loadmore"
        }
    }
}

wxc-loadmore 即爲頭像組件的標籤名,能夠在 wxml 中使用。

六、在 wxml 中使用 wxc-loadmore標籤。

home/index.wxp 文件的 template 中添加 wxc-loadmore 標籤,代碼以下:

<wxc-loadmore is-end="{{true}}"></wxc-loadmore>

七、打開微信開發者工具,指定 dist 目錄,預覽項目。

home/index.wxp 文件的代碼以下所示:

<!-- home/index.wxp -->
<template>
  <wxc-loadmore is-end="{{true}}"></wxc-loadmore>
</template>

<script>
export default {
  config: {
    usingComponents: {
      'wxc-loadmore': '@minui/wxc-loadmore'
    }
  },
  data: {}
}
</script>

<style>
</style>

圖示:

default

至此,minui 組件庫的 loadmore 頁底組件在 Min 工具生成的小程序項目中的方法已介紹完畢,其餘場景,在原生小程序或其餘小程序框架項目中的使用方式請移步至以下連接:

在已有小程序項目中使用 MinUI 組件介紹

瞭解組件的使用方式後,下面開始介紹 loadmore 組件的 API 。

Loadmore【props】

名稱 描述
is-end [說明]:是否到底。
[類型]:Boolean
默認值:true
icon [說明]:圖標。設爲true的時候,調用默認圖標
[類型]:String
[默認值]:[到底]隨機 / [加載] loading
text [說明]:文案。
[類型]:String
[默認值]:[到底]隨機 / [加載] 加載中...

更多demo

一、只有文字到底

<template>
  <wxc-loadmore
    is-end="{{true}}"
    text="到底啦"
  >
  </wxc-loadmore>
</template>

<script>
export default {
  config: {
    usingComponents: {
      'wxc-loadmore': '@minui/wxc-loadmore'
    }
  },
  data: {}
}
</script>

<style>
</style>

圖示:

只有到底文字

二、自定義 icon

<template>
  <wxc-loadmore
    is-end="{{true}}"
    text="到底啦"
    icon="https://s10.mogucdn.com/mlcdn/c45406/171016_47j96cl3hdhhdf7ajg8hg2kd13gdc_400x400.png"
  >
  </wxc-loadmore>
</template>

<script>
export default {
  config: {
    usingComponents: {
      'wxc-loadmore': '@minui/wxc-loadmore'
    }
  },
  data: {}
}
</script>

<style>
</style>

圖示:

icon

三、自定義到底文案

<template>
  <wxc-loadmore is-end="{{true}}" text="到底了~" icon="{{true}}"></wxc-loadmore>
</template>

<script>
export default {
  config: {
    usingComponents: {
      'wxc-loadmore': '@minui/wxc-loadmore'
    }
  },
  data: {}
}
</script>

<style>
</style>

圖示:

自定義文案

四、加載中

<template>
  <wxc-loadmore></wxc-loadmore>
</template>

<script>
export default {
  config: {
    usingComponents: {
      'wxc-loadmore': '@minui/wxc-loadmore'
    }
  },
  data: {}
}
</script>

<style>
</style>

圖示:

加載中

五、加載中—自定義文案

<template>
  <wxc-loadmore
    text="正在努力加載中..."
    icon="{{true}}"
  >
  </wxc-loadmore>
</template>

<script>
export default {
  config: {
    usingComponents: {
      'wxc-loadmore': '@minui/wxc-loadmore'
    }
  },
  data: {}
}
</script>

<style>
</style>

圖示:

加載中-自定義文案

六、加載中—自定義icon

<template>
  <wxc-loadmore
    text="正在努力加載中..."
    icon="https://s10.mogucdn.com/mlcdn/c45406/171018_8gj08gbl9fj6igb380dec9k1ifhe2_32x32.png"
  >
  </wxc-loadmore>
</template>

<script>
export default {
  config: {
    usingComponents: {
      'wxc-loadmore': '@minui/wxc-loadmore'
    }
  },
  data: {},
  methods: {}
}
</script>

<style>
</style>

圖示:

加載中-自定義icon

更多組件更新同步請關注 MinUI 小程序組件庫示例查看,或請移步到實時同步更新的 微信小程序 loadmore 頁底組件使用文檔

溝通反饋

請添加羣助手 wUf18018252882 好友或者掃碼加好友,並與羣助手對話發送驗證碼 10088 按照指引進羣。

羣二維碼

相關連接

開源組件


蘑菇街前端團隊,2018.01.19 於杭州

相關文章
相關標籤/搜索