ViewBox
Install

Install

该组件为100%高布局,可以解决部分键盘输入的问题,但是同时会在safari中出现向下滚动时无法自动隐藏url工具栏和底部栏的问题。

viewBox里元素定位为absolute,效果等同于fixed

使用时需要设置 html, body 高为100%:

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

view-box所有父div也需要为100%高度:

<div style="height:100%;">
  <view-box ref="viewBox">
    <x-header slot="header" style="width:100%;position:absolute;left:0;top:0;z-index:100;"></x-header>
    <router-view></router-view>
    <tabbar slot="bottom"></tabbar>
  </view-box>
</div>

如果你想保存滚动距离,推荐使用vuex实现,在特定pathscrollBody监听scroll事件,并获取滚动距离保存到vuexstate里。示例可以参考vux源码的App.vue


API

Props

nametypedefaultdescriptionrequired version
body-padding-topstring--
body-padding-bottomstring--

Slots

namedescriptionrequired version
header--
default--
bottom--

Functions

nameparamsdescriptionrequired version
scrollTo(top)
getScrollTop
getScrollBody


Contributors

Contributors

Total commits quantity: 1,Total contributors quantity: 1

Bobjoy

Changelog

Releases