当前位置: 首页> 财经> 产业 > 深圳的小程序开发公司_怎么彻底删除2345网址导航_关键词搜索网站_石家庄seo优化

深圳的小程序开发公司_怎么彻底删除2345网址导航_关键词搜索网站_石家庄seo优化

时间:2025/7/12 4:55:26来源:https://blog.csdn.net/hammer1010/article/details/143082775 浏览次数:0次
深圳的小程序开发公司_怎么彻底删除2345网址导航_关键词搜索网站_石家庄seo优化

没有特别的幸运,那么就特别的努力!!!

配置信息

官方给出:
在 app.config 中按正常填写 tabBar 项的相关配置(为了向下兼容),并把 tabBar 项的 custom 字段设置为 true。但我试过 custom设置为 false 才生效

1.app.config.js 文件配置

// app.config.js
export default defineAppConfig({pages: ["pages/index/index", "pages/complaint/index", "pages/mine/index"],window: {backgroundTextStyle: "light",navigationBarBackgroundColor: "#fff",navigationBarTitleText: "WeChat",navigationBarTextStyle: "black",},tabBar: {custom: false,color: "#000000",selectedColor: "#DC143C",backgroundColor: "#ffffff",list: [{pagePath: "pages/index/index",selectedIconPath: "images/tabbar_home_on.png",iconPath: "images/tabbar_home.png",text: "首页",},{pagePath: "pages/mine/index",selectedIconPath: "images/tabbar_my_on.png",iconPath: "images/tabbar_my.png",text: "个人中心",},],},
});

2.添加 custom-tab-bar

在 src 目录下添加 custom-tab-bar 目录,在里面书写组件,支持 React、Vue 和原生写法。

├── config
├── src
|   └── custom-tab-bar
|       ├── index.config.ts
|       └── index.tsx
└── package.json
// src/custom-tab-bar/index.tsx
import { Component } from 'react'
import Taro from '@tarojs/taro'
import { CoverView, CoverImage } from '@tarojs/components'import './index.scss'export default class Index extends Component {state = {selected: 0,color: '#000000',selectedColor: '#DC143C',list: [{pagePath: '/pages/index/index',selectedIconPath: '../images/tabbar_home_on.png',iconPath: '../images/tabbar_home.png',text: '首页'},{pagePath: '/pages/mine/index',selectedIconPath: '../images/tabbar_my_on.png',iconPath: '../images/tabbar_my.png',text: '个人中心'}]}switchTab(index, url) {this.setSelected(index)Taro.switchTab({ url })}setSelected (idx: number) {this.setState({selected: idx})}render() {const { list, selected, color, selectedColor } = this.statereturn (<CoverView className='tab-bar'><CoverView className='tab-bar-border'></CoverView>{list.map((item, index) => {return (<CoverView key={index} className='tab-bar-item' onClick={this.switchTab.bind(this, index, item.pagePath)}><CoverImage src={selected === index ? item.selectedIconPath : item.iconPath} /><CoverView style={{ color: selected === index ? selectedColor : color }}>{item.text}</CoverView></CoverView>)})}</CoverView>)}
}

3.底部组件都需要引入

// src/page/mine/index.tsx
import { View, Text } from '@tarojs/components'
import Taro,{ useLoad } from '@tarojs/taro'
import './index.scss'import type CustomTabBar from '../../custom-tab-bar'export default function Mine () {const pageCtx = Taro.getCurrentInstance().pageuseLoad(() => {const tabbar = Taro.getTabBar<CustomTabBar>(pageCtx)tabbar?.setSelected(1)})return (<View className='mine'><Text>mine-1</Text></View>)
}

希望能帮助到大家,同时祝愿大家在开发旅途中愉快!!!

拿着 不谢 请叫我“锤” !!!

关键字:深圳的小程序开发公司_怎么彻底删除2345网址导航_关键词搜索网站_石家庄seo优化

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: