With the in-depth development of the mobile Internet, more and more companies choose to build their own APPs to improve user experience and brand image. In order to reduce development costs and improve development efficiency, many companies choose to use cross-platform development frameworks to build APPs, and Uniapp is an excellent open source framework among them.
When building a Uniapp application, we need to define the entry page, which is the page that is loaded first after the application is started. It is usually called the landing page or home page. In this article, we will detail how to create and set up a landing page for your Uniapp application.
Step one: Create Uniapp project
Download the latest version of Uniapp from the Uniapp official website and install it in the local environment:
$ npm install --global @vue/cli@3.0.0-beta.10 $ vue create -p dcloudio/uni-preset-vue my-project
Enter the above command on the command line, that is A uni-app project can be created.
Step 2: Create a landing page
In the src directory, we can create our own homepage vue page. You can choose your favorite editor to write. Here we use the HbuilderX editor to create an index.vue file. The code is as follows:
<template> <view> <text>这是我的Uniapp应用程序的落地页</text> </view> </template> <style> .container { height: 100vh; display: flex; justify-content: center; align-items: center; } .text { font-size: 24px; } </style>
Simply put, we created a container tag and a text tag. The container Used to center text content and make it appear centered. For demonstration purposes here, the text content we set is just "This is the landing page of my Uniapp application".
Step 3: Set up the landing page
After we create the landing page, we need to tell the Uniapp application that this is our entry page and need to be configured in the pages.json file. Open the pages.json file and add the following code:
{ "pages": [ { "path": "pages/index/index", "style": { "navigationBarTitleText": "Uniapp落地页" } } ], "globalStyle": { "navigationBarTextStyle": "white", "navigationBarBackgroundColor": "#000" } }
In this pages.json file, we define all the pages of the application, there is only the "index" page we just created. The "navigationBarTitleText" attribute is used to set the navigation bar title text. In addition, we should also set the global navigation bar style.
Step 4: Set the application startup page
We have set the landing page, but we also need to tell Uniapp what the application startup page is. Add the following content to the pages.json file:
{ "pages": [ { "path": "pages/index/index", "style": { "navigationBarTitleText": "Uniapp落地页" } } ], "globalStyle": { "navigationBarTextStyle": "white", "navigationBarBackgroundColor": "#000" }, "tabBar": { "list": [ { "pagePath": "pages/index/index", "text": "首页", "iconPath": "static/tabbar/home.png", "selectedIconPath": "static/tabbar/home-active.png" } ] }, "launchPage": { "path": "pages/index/index" } }
Here we use the tabBar and launchPage attributes. tabBar is used to define the bottom navigation bar of the application, and launchPage is used to set the application launch page. We set the startup page to the "index" page we just created.
Here we also need to define several properties for the bottom navigation bar of the application. Only one "homepage" is defined here. Other pages can be defined according to needs, and the iconPath and selectedIconPath properties are used to define navigation. The icon corresponding to the bar and the icon of the active state.
Step 5: Start the application
Now that we have set up the landing page and startup page, we can start the application to see the effect. Enter the following command in the command console to start the application:
$ npm run dev:%PLATFORM%
The %PLATFORM% here represents the platform you are using later, which can be h5, app-plus, mp-weixin and other platforms.
Now, we have successfully created and set up the landing page of the Uniapp application. Whether you are building a web application or a cross-platform mobile application, Uniapp is a powerful development framework that allows you to create impressive applications.
The above is the detailed content of How to set up landing page in uniapp. For more information, please follow other related articles on the PHP Chinese website!

This article details uni-app's local storage APIs (uni.setStorageSync(), uni.getStorageSync(), and their async counterparts), emphasizing best practices like using descriptive keys, limiting data size, and handling JSON parsing. It stresses that lo

This article details workarounds for renaming downloaded files in UniApp, lacking direct API support. Android/iOS require native plugins for post-download renaming, while H5 solutions are limited to suggesting filenames. The process involves tempor

This article addresses file encoding issues in UniApp downloads. It emphasizes the importance of server-side Content-Type headers and using JavaScript's TextDecoder for client-side decoding based on these headers. Solutions for common encoding prob

This article details uni-app's geolocation APIs, focusing on uni.getLocation(). It addresses common pitfalls like incorrect coordinate systems (gcj02 vs. wgs84) and permission issues. Improving location accuracy via averaging readings and handling

This article compares Vuex and Pinia for state management in uni-app. It details their features, implementation, and best practices, highlighting Pinia's simplicity versus Vuex's structure. The choice depends on project complexity, with Pinia suita

This article details making and securing API requests within uni-app using uni.request or Axios. It covers handling JSON responses, best security practices (HTTPS, authentication, input validation), troubleshooting failures (network issues, CORS, s

The article details how to integrate social sharing into uni-app projects using uni.share API, covering setup, configuration, and testing across platforms like WeChat and Weibo.

This article explains uni-app's easycom feature, automating component registration. It details configuration, including autoscan and custom component mapping, highlighting benefits like reduced boilerplate, improved speed, and enhanced readability.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools
