Home  >  Article  >  Web Front-end  >  How to change the icon in uniapp

How to change the icon in uniapp

藏色散人
藏色散人Original
2020-12-18 17:52:3614667browse

How to change the icon in uniapp: first put the "iconfont.ttf" in the icon file into the static folder; then open "iconfont.css" and check the unicode encoding; finally fill in the encoding of the corresponding icon Just go to the text in the configuration item of "page.json".

How to change the icon in uniapp

The operating environment of this tutorial: Windows 7 system, uni-app2.5.1 version. This method is suitable for all brands of computers.

Recommended (free): uni-app development tutorial

UNI-APP adds a top navigation bar and changes the icon

uni-app is a front-end framework for developing cross-platform applications using Vue.js.

Developers write Vue.js code, and uni-app compiles it to multiple platforms such as iOS, Android, and WeChat applets to ensure that it runs correctly and achieves an excellent experience.

Record the process of replacing the top navigation bar

How to change the icon in uniapp

Final renderings

Configuration items in page.json

{
            "path": "pages/my/index",
            "style": {
                "app-plus": {
                    "titleNView": {
                        "buttons": [{
                                "text": "\ue605",
                                "fontSrc": "/static/iconfont.ttf",
                                "fontSize": "22px",
                                "float": "left"
                            },
                            {
                                "text": "\ue606",
                                "fontSrc": "/static/iconfont.ttf",
                                "fontSize": "22px"
                            }
                        ]
                    }
                }
            }
        },


Change Icon

1. Select your favorite icon from the Alibaba vector image, and then click Favorite

How to change the icon in uniapp

Collect icons

2. Download all the icons that have been collected in the upper right corner

How to change the icon in uniapp

Download

3. Open the downloaded file in the editor, drop the iconfont.ttf in the file into the static folder, and then open iconfont.css to view the unicode encoding

How to change the icon in uniapp

unicode encoding

4. Finally, fill in the encoding of the corresponding icon into the text in the configuration item of page.json. It needs to be written as "\u***", and then restart to achieve it.

5.Finally Fill in the corresponding page life cycle method and configure different methods through e.index

      onNavigationBarButtonTap:function(e){
            console.log(JSON.stringify(e))
        },

The above is the detailed content of How to change the icon in uniapp. 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