移动端tabbar遮挡文档内容后解决方法

1.情况说明

如图是在调试环境下数据的显示情况,数据的最后一条(再试一下)并没有显示出来

2.解决方法:

前提:定义tabbar且固定tabbar的高度为48px:

这里提供了两种思路,但是用的都是一种方法;(2选1即可解决方法)

1.使用自带的组件group传递padding-bottom属性;

//wxml

<van-cell-group inset style="--height--:{{bottom_height}}px;">
  <van-cell wx:for="{{List}}" wx:for-item="item" wx:key="id" title="{{item.title}}" value="{{item.content}}" label="{{item.Time}}" />
</van-cell-group>
//wxss

.van-cell-group{
  padding-bottom:var(--height--);
}
//js

Page({
    data: {
    bottom_height: 0,
  },
  onLoad: function (options) {
    const res = wx.getSystemInfoSync()
    this.setData({
      bottom_height: 54 + res.screenHeight - res.safeArea.bottom
    })
    console.log(res);
  },
})

2.在页面的底部加一个空的view,并且设置height属性;

//wxml

<view class="footer" style="--height--:{{bottom_height}}px;"></view>
//wxss

.footer{
  height:var(--height--);
}

js部分代码是一致的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
对于Vue 3和Vant移动端TabBar的使用,你可以按照以下步骤进行操作: 1. 首先,确保你已经安装了Vue 3和Vant。你可以使用以下命令来安装它们: ```bash npm install vue@next vant ``` 2. 在你的Vue项目中,创建一个新的组件文件,例如`TabBar.vue`。 3. 在`TabBar.vue`文件中,引入Vue和Vant的相关组件和样式: ```javascript <template> <div> <van-tabbar v-model="active"> <van-tabbar-item icon="home-o" to="/"> 首页 </van-tabbar-item> <van-tabbar-item icon="search" to="/search"> 搜索 </van-tabbar-item> <van-tabbar-item icon="star-o" to="/favorites"> 收藏 </van-tabbar-item> <van-tabbar-item icon="contact" to="/profile"> 个人中心 </van-tabbar-item> </van-tabbar> </div> </template> <script> import { Tabbar, TabbarItem } from 'vant'; export default { components: { [Tabbar.name]: Tabbar, [TabbarItem.name]: TabbarItem, }, data() { return { active: '/', }; }, }; </script> <style> /* 这里可以添加自定义样式 */ </style> ``` 4. 在你的主应用组件中,例如`App.vue`,使用`TabBar`组件: ```html <template> <div id="app"> <!-- 其他内容 --> <TabBar /> </div> </template> <script> import TabBar from './components/TabBar.vue'; export default { components: { TabBar, }, }; </script> <style> /* 这里可以添加全局样式 */ </style> ``` 5. 最后,你可以根据自己的需要在`TabBar.vue`中设置每个Tab项的图标、文字和链接。你还可以通过修改`active`的值来控制当前选中的Tab。 这样,你就可以在Vue 3项目中使用Vant移动端TabBar了。记得根据自己的需求进行样式和功能的调整。希望对你有帮助!如果有任何问题,请随时提问。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值