欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

微信小程序开发之选项卡(窗口底部TabBar)页面切换

程序员文章站 2024-02-02 22:31:46
微信小程序开发中窗口底部tab栏切换页面很简单很方便. 代码: 1.app.json //app.json { "pages":[ "p...

微信小程序开发中窗口底部tab栏切换页面很简单很方便.

微信小程序开发之选项卡(窗口底部TabBar)页面切换

代码:

1.app.json

//app.json 
{ 
 "pages":[ 
  "pages/index/index", 
  "pages/logs/logs" 
 ], 
 "window":{ 
  "backgroundtextstyle":"light", 
  "navigationbarbackgroundcolor": "#999999", 
  "navigationbartitletext": "tab", 
  "navigationbartextstyle":"white" 
 }, 
  "tabbar": { 
  "color": "#ccc", 
  "selectedcolor": "#35495e", 
  "borderstyle": "white", 
  "backgroundcolor": "#f9f9f9", 
  "list": [ 
   { 
    "text": "首页", 
    "pagepath": "pages/index/index", 
    "iconpath": "images/home.png", 
    "selectediconpath": "images/home-actived.png" 
   }, 
   { 
    "text": "目录", 
    "pagepath": "pages/catalogue/catalogue", 
    "iconpath": "images/note.png", 
    "selectediconpath": "images/note-actived.png" 
   }, 
   { 
    "text": "我的", 
    "pagepath": "pages/mine/mine", 
    "iconpath": "images/profile.png", 
    "selectediconpath": "images/profile-actived.png" 
   } 
  ] 
 } 
} 

pagepath是页面路径.iconpath是图片路径,icon 大小限制为40kb.

selectediconpath:选中时的图片路径,icon 大小限制为40kb

tab bar的最多5个,最少2个.

在pages目录下写好页面即可切换.

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!