Home >Web Front-end >uni-app >uniapp removes startup page

uniapp removes startup page

PHPz
PHPzOriginal
2023-05-22 10:16:062192browse

With the development of the mobile application market, users are paying more and more attention to the experience of using mobile applications. The startup page, as one of the entrances to the application, also needs to be optimized as much as possible to reduce loading time and improve user experience. For applications developed using uniapp, it is also possible to remove the startup page. This article will introduce how to remove the startup page in uniapp.

1. What is the uniapp startup page?

Before introducing how to remove the uniapp startup page, you first need to understand what the uniapp startup page is. The uniapp startup page refers to an interface with the application icon and name that appears on the mobile phone interface when the application is opened. Generally speaking, there are two situations:

  1. Custom startup page
    In uniapp, we can customize the style and content of the startup page, such as setting a background image, adding our own LOGO, etc.
  2. Default startup page
    When we do not set a custom startup page, the default uniapp startup page will be automatically loaded. This startup page is a code developed by the uniapp technical team. It is characterized by simplicity and speed. , easy to use.

2. Why should we remove the uniapp startup page

Although the startup page can improve the quality and user experience of the application, in some cases, we also need to remove the startup page. The following are Some typical examples:

  1. Speed ​​up application startup speed
    Although the startup page is a way to improve the quality of applications, because it needs to load HTML, CSS, JS and other files, some applications The startup speed may be affected by the startup page. In this case, you need to consider removing the startup page to speed up the application startup speed.
  2. Save user traffic
    Loading the startup page requires user traffic. For some applications that use billing strategies, you can consider removing the startup page to save user traffic.
  3. Reduce application size
    The startup page needs to load HTML, CSS, JS and other files. Although these files are small, when the application size is large, removing the startup page can reduce the size of the application and improve user experience. Download and installation experience.

3. How to remove the uniapp startup page

If you decide to remove the uniapp startup page, what should you do? Two implementation methods are introduced below, as follows:

  1. Method 1: Modify the uni-app framework source code

On the Android platform, we can modify uni- app framework source code to remove the startup page. The specific steps are as follows:

  1. Open the vue.config.js file in the project root directory and modify it as follows:
module. exports = {
  // ...
  configureWebpack: {
    plugins: [
      // 去掉Uni-app默认的启动页
      new RemoveWebpackPlugin([/^/?__uni__default/])
    ]
  }
}
  1. Run npm install in the project root directory @intervolga/optimize-cssnano-plugin, install the cssnano plug-in.
  2. Just remove the definition of "activity-alias" in the manifest.xml file of the android code.
  3. Method 2: By calling the API encapsulated by uni-app

On the iOS platform, we can remove the startup page by calling the API encapsulated by uni-app:

  1. When calling the launchWebview method of the plus.navigator class, set splash: 'none'.
plus.navigator.launchWebview(
  "",
  "com.dcloud.uniapp",
  {},
  {
    "uni-app": true,
    splash: 'none',
  }, // 启动参数为界面id
  (e) => {
    // 执行你想执行的方法
  },
  (e) => {
    // 错误处理
  }
);

Through the above two methods, you can easily remove the startup page of uniapp.

4. Summary

The startup page is an important part of the application, which can improve the quality and user experience of the application. However, there are also some situations where the startup page needs to be removed. This article introduces how to remove the startup page from uniapp. There are two implementation methods, I hope it will be helpful to you. If you have questions about other issues with uniapp, you can go to the uniapp official website or the community for help.

The above is the detailed content of uniapp removes startup page. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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