搜尋
首頁微信小程式小程式開發從零開始開發微信小程式步驟(三)

從零開始開發微信小程式步驟(三)

Mar 21, 2018 am 09:46 AM
小程式步驟程式

前面我們和大家分享如何建立一個新的頁面和設定頁面的標題,這一章我們來聊聊底部導覽列是如何實現的。即點擊底部的導航,會實現不同對應頁面之間的切換。我們先來看看我們要實現的底部導覽列的效果圖:(三個導航圖示範例,微信小程式最多能加5個)。




1.圖示準備

阿里圖標庫 http://www.iconfont.cn/collections/show/29

在這個網站上下載一些自己要用到的圖標,例如人員頭像,home主頁等一些常用的圖標,直接點擊下載儲存到本地,修改一下命名。也可以使用UI準備好的圖示。

回到專案裡,新建一個images資料夾,將剛下載好的圖示放在資料夾底下備用,將上述起好名字的圖示儲存到小程序專案目錄中新建立的images 資料夾中,準備工作就做好了。


#2. 新增設定檔

我們找到專案根目錄中的設定檔app.json 加入以下設定資訊(app.json檔案用來對微信小程式進行全域配置,決定頁面檔案的路徑、視窗表現、設定網路逾時時間、設定多tab 等。)

   "tabBar": {  "color": "#a9b7b7",  "selectedColor": "#11cd6e",  "borderStyle": "white",  "list": [
    {      "selectedIconPath": "images/1.png",      "iconPath": "images/2.png",      "pagePath": "pages/index/index",      "text": "首页"
    },
    {      "selectedIconPath": "images/1.png",      "iconPath": "images/2.png",      "pagePath": "pages/logs/logs",      "text": "日志"
    },
    {      "selectedIconPath": "images/1.png",      "iconPath": "images/2.png",      "pagePath": "pages/test/test",      "text": "测试"
    }
  ]
}

以上只是基礎的部分,當然了小程式的官方文件提供了更多的豐富的元件和樣式
參考文件:
https://mp.weixin .qq.com/debug/wxadoc/dev/framework/config.html#tabBar

#OK,結束,儲存編譯 就可以實現小程式的經典的底部導航效果了

#== ============
附錄:一份完整程式碼(可忽略不計)

#圖片.png

{  "pages":[        "pages/index/index",        "pages/category/category",        "pages/topic/topic",        
        "pages/user/user",        "pages/logs/logs"
  ],  "window":{        "backgroundTextStyle":"light",        "navigationBarBackgroundColor": "#000",        "navigationBarTitleText": "WeiCMS",        "navigationBarTextStyle":"white"
  },  "tabBar": {    "color": "#8c8c8c",    "selectedColor": "#f4645f",    "backgroundColor": "white",    "list": [{      "pagePath": "pages/index/index",      "text": "首页",      "iconPath":"images/48.png",      "selectedIconPath":"images/48.png"
    }, 
    {      "pagePath": "pages/category/category",      
      "text": "分类",      "iconPath":"images/48.png",      "selectedIconPath":"images/48.png"
    },
    {      "pagePath": "pages/topic/topic",      
      "text": "话题",      "iconPath":"images/48.png",      "selectedIconPath":"images/48.png"
    },
    {      "pagePath": "pages/user/user",      
      "text": "我的",      "iconPath":"images/48.png",      "selectedIconPath":"images/48.png"
    }  
    ],    "position": "bottom"
  }  
}

相關推薦:

從零開始開發微信小程式(一)

從零開始開發微信小程式(二)

微信小程式簡單介紹

#

以上是從零開始開發微信小程式步驟(三)的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱工具

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

EditPlus 中文破解版

EditPlus 中文破解版

體積小,語法高亮,不支援程式碼提示功能