Home > Web Front-end > uni-app > body text

In-depth discussion on where to place the uniapp icon

PHPz
Release: 2023-04-06 09:22:08
Original
1350 people have browsed it

With the increasing development of the mobile application market, developers are paying more and more attention to the user experience and aesthetics of the application. In addition to implementing functions, how to design a more attractive application interface has also become a question that developers need to think about. Among them, the importance of icon design is self-evident. In uniapp, how to place icons is also a concern for some beginners. In this article, we’ll delve into this issue.

First of all, what you need to know is that uniapp is a cross-platform development framework based on the Vue.js framework. It can help developers develop the same application on different platforms, and can realize the functions of some native applications. Therefore, icon placement in uniapp is divided into three different platforms: H5, mini program and App.

For the H5 platform, we can place the icon image in the "static" folder in the project root directory to facilitate external calls. At the same time, you need to use the link tag in the index.html file to introduce the icon file. The code is as follows:

<link rel="icon" type="image/png" href="/static/favicon.png" />
Copy after login

Among them, the href path is the path where the icon image is actually placed.

For the mini program platform, because mini programs have various components, developers can choose the placement location according to their needs. For example, you can place the icon image in the "images" folder in the root directory of the mini program, and use the image component to reference the image. The code is as follows:

<image src="/images/icon.png"></image>
Copy after login

In addition, in the mini program developer tools, You can specify the icon of the application by setting the APP.json file of the mini program, for example:

"tabBar": {
    "color": "#a9b7b7",
    "selectedColor": "#007aff",
    "list": [
      {
        "pagePath": "pages/index/index",
        "iconPath": "/images/tabBar/home.png",
        "selectedIconPath": "/images/tabBar/homeActive.png",
        "text": "首页"
      }
    ]
  },
  "window": {
    "navigationBarTitleText": "uniapp",
    "navigationBarBackgroundColor": "#007aff",
    "backgroundColor": "#f5f5f5",
    "backgroundTextStyle": "dark",
    "enablePullDownRefresh": true,
    "navigationBarTextStyle": "white",
    "backgroundRemoteDebug": true,
    "usingComponents": {}
  }
Copy after login

Finally, for the development of the App platform, it needs to be in the "/unpackage/dist/build/app-plus/" directory Place the icon image in the folder with the same name under the folder, and add the following code in the manifest.json file:

"appPlus": {
    "appid": "HBuilderX_1.0.0",
    "name": "uniapp",
    "version": "1.0.0",
    "description": "uniapp",
    "icon": "/static/icons/logo.png",
    "orientation": "portrait",
    "plusSettings": {
      "streamingMode": "none"
    },
    "permission": [
      "audio",
      "camera"
    ]
  }
Copy after login

The icon path here is also the path where the icon image is actually placed.

To sum up, we can use the above method to place icon images on different platforms and complete the references. For beginners, what needs to be noted is the differences and special treatments for different platforms. At the same time, the specific placement method can also be changed according to actual needs. Finally, I hope that everyone can design a more beautiful and practical icon interface for the application during the development process.

The above is the detailed content of In-depth discussion on where to place the uniapp icon. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!