html实现tabber按钮,tabbar.html

Document

.title {

float: left;

cursor: pointer;

padding: 5px 20px;

border: 1px solid #ccc;

border-top-left-radius: 6px;

border-top-right-radius: 6px;

background-color: orange;

color: honeydew;

}

.active {

background-color: #abd;

border-bottom: 1px solid transparent;

}

.clear {

clear: both;

}

#content {

width: 500px;

height: 500px;

padding: 10px;

position: relative;

top: -1px;

z-index: -1;

border: 1px solid #ccc;

background: linear-gradient(to bottom, #abd, #ffffff);

}

.input {

display: block;

width: 400px;

height: 40px;

line-height: 40px;

margin: 0 auto;

border-radius: 6px;

border: 2px solid #56a5f1;

padding-left: 20px;

font-size: 18px;

color: #666;

outline: none;

}

单曲
歌词
其他

let contentList = [];

let indexPage = `这是首页的内容`;

let newsPage = `这是新闻的内容`;

let musicPage = `这是音乐的内容`;

contentList.push(indexPage, newsPage, musicPage);

// 默认显示首页内容

content.innerHTML = contentList[0]

// 选中按钮

let btns = document.querySelectorAll('.title');

// 获取当前选中的元素

let currentBtns = btns[0]

for(let i=0;i < btns.length; i ++) {

// 通过for循环给每一个按钮增加属性并绑定事件

let obj = btns[i];

// 新增btnIndex属性,作为编号

obj.btnIndex = i;

// 绑定单击事件

obj.onclick = function(e) {

// 替换对应的内容

content.innerHTML = contentList[e.target.btnIndex];

// 移除class

currentBtns.classList.remove('active');

// e.target.classList.add('active');

// 给当前元素增加class

this.classList.add('active');

// 更新当前元素

currentBtns = e.target

}

}

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在uniapp中,可以通过设置tabbar的midButton属性来实现tabbar导航栏中间的发布按钮设置为大图标,并通过调用uni.onTabBarMidButtonTap实现页面跳转。具体实现方法如下: 1. 在App.vue文件中,使用uni.onTabBarMidButtonTap方法监听发布按钮的点击事件,并在回调函数中使用uni.navigateTo方法进行页面跳转。示例代码如下: ```javascript uni.onTabBarMidButtonTap(function() { uni.navigateTo({ url: '/pages/circle/circle' }) }) ``` 2. 在index.vue文件中,可以使用canvas画布将图标画到tabbar对应位置上,并监听点击事件进行页面跳转。示例代码如下: ```javascript methods: { createtab: function() { // 设置水平居中位置 var leftPos = Math.ceil((plus.screen.resolutionWidth - 50) / 2); var view = new plus.nativeObj.View('icon', { bottom: '19px', left: leftPos + 'px', width: '50px', height: '50px' }); // 使用canvas画布把图标画到tabbar对应位置上 view.drawBitmap(bitmap, { tag: 'font', id: 'icon', src: '/static/app-tabber/app-tabber.png', position: { top: '0px', left: '5px', width: '50px', height: '100%' } }); // 监听界面跳转 view.addEventListener("click", function(e) { uni.switchTab({ url: '/pages/circle/circle' }) }, false); view.show(); } } ``` 通过以上方法,你可以实现在uniapp中点击tabbar按钮进行图片转换和页面跳转的功能。 #### 引用[.reference_title] - *1* *3* [uniapp 实现tabBar图标凸起的两种方式(App端)](https://blog.csdn.net/weixin_45788691/article/details/107672635)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [【uni-app】app界面TabBar中间大图标设置的两种方法:midButton的使用;iconfont的使用](https://blog.csdn.net/aDiaoYa_/article/details/131124857)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值