Home Web Front-end uni-app Hide the top navigation bar on the uniapp homepage

Hide the top navigation bar on the uniapp homepage

Apr 20, 2023 pm 03:01 PM

In mobile application development, it is often necessary to hide certain elements on the page. For example, in uniapp, hiding the top navigation bar on the homepage is a common requirement. This article will introduce how to use the API provided by uniapp to implement this function.

In uniapp, the basic structure of all pages is as follows:

<code><template>
  <view class="container">
    <!-- 页面内容 -->
  </view>
</template>

<script>
export default {
  data() {
    return {
      // 页面数据
    };
  },
  // 页面生命周期钩子函数
  onLoad() {},
  onReady() {},
  onShow() {},
  onHide() {},
  // ...
};
</script></code>
Copy after login

Among them, the <view class="container"> tag is used to wrap the content of the page, If you want to hide the top navigation bar, just add a special attribute navigation-bar-fixed on the <view> tag. Specifically, change the <view> tag to the following form:

<code><view class="container" navigation-bar-fixed>
  <!-- 页面内容 -->
</view></code>
Copy after login

In this way, the top navigation bar in the page will be hidden. It is important to note that since navigation-bar-fixed is a custom attribute, it must be defined in the style of the page, otherwise the navigation bar will not be hidden. The style is defined as follows:

<code><style>
.container {
  height: 100%; /* 设置页面容器高度为100% */
}
app-uni-status-bar,
app-uni-nav-bar,
page-body {
  display: none; /* 隐藏系统自带的顶部状态栏和导航栏 */
}
</style></code>
Copy after login

It should be noted that the app-uni-status-bar, app-uni-nav-bar and page-body respectively represent the top status bar, navigation bar and page content area that comes with the system. They need to be hidden at the same time to achieve a complete navigation bar hiding effect.

To sum up, by adding custom attributes and modifying the page style, we can easily implement the function of hiding the top navigation bar in uniapp.

The above is the detailed content of Hide the top navigation bar on the uniapp homepage. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1270
29
C# Tutorial
1250
24