


How to solve the problem that uniapp configuration meta does not take effect
Uniapp is a cross-platform application development framework based on Vue.js. It is simple to develop and easy to use. It can quickly build iOS, Android and H5 pages and has become one of the important tools for mobile application development today. However, the development of cross-platform applications also brings some problems. For example, this article solves the problem that the uniapp page configuration meta does not take effect. I hope it will be helpful to readers.
Problem Description
Recently, some developers have reported that in the H5 page built using uniapp, the configured meta tag does not take effect. That is, when viewing the website source code in the browser, the corresponding meta cannot be found. Label. However, it can be displayed normally in the preview of the development tool and the viewing page on the mobile phone.
Problem Solving
- Confirm whether the meta content is correct
First you need to ensure that the content of the meta tag is correct, configure it in the page.json of uniapp:
"meta": { "viewport": "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no", "keywords": "uniapp, meta, 问题, 解决", "description": "uniapp 配置 meta 不生效的解决方法", "apple-mobile-web-app-capable": "yes", "apple-mobile-web-app-status-bar-style": "black", "format-detection": "telephone=no,email=no,address=no" }
Among them, viewport, keywords, and description are necessary meta tags, and other meta tags can be added for personalized configuration.
- Add meta tag in index.html
If the corresponding tag does not exist in the page source code after configuring meta in page.json, you need to add it in the uniapp project Manually add the meta tag to index.html. For example, add the meta tag of viewport in the head tag:
<meta>
If you need to add other meta tags, please refer to the configuration in step 1.
- Confirm uniapp packaging configuration
If the problem cannot be solved in the first two steps, you need to confirm the uniapp packaging configuration, which mainly includes the following two aspects:
- Whether the packaging path is configured in uniapp's manifest.json
manifest.json is the configuration file built by uniapp, in which the packaging path needs to be set. Specifically, you need to add the page path to be packaged in the weex > appboard > src attribute or h5 > router > pages attribute in manifest.json.
// weex > appboard > src 示例 "weex": { "appName": "UniApp", "appBoard": "/index.vue", "pages": [ "pages/tabbar/index/index", "pages/tabbar/quick-work/quick-work", "pages/tabbar/find/find", "pages/tabbar/mine/mine" ] } // h5 > router > pages 示例 "h5": { "custom": { "titleNView": true, "scrollIndicator": "none" }, "router": { "mode": "hash", "pages": [ { "path": "/", "style": { "navigationBarTitleText": "首页" }, "query": "", "meta": { "viewport": "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no", "keywords": "uniapp, h5, 打包配置, manifest.json", "description": "uniapp 配置 meta 不生效的解决方法", "apple-mobile-web-app-capable": "yes", "apple-mobile-web-app-status-bar-style": "black", "format-detection": "telephone=no,email=no,address=no" } } ] } }
- Whether the packaging path is configured in vue.config.js of uniapp
In addition to configuring the packaging path in manifest.json, you can also configure it in the uniapp project's Configure in the vue.config.js file in the root directory, mainly in the outputDir and pages attributes:
module.exports = { outputDir: 'dist/h5', pages: { index: { entry: 'src/main.js', template: 'public/index.html', filename: 'index.html', title: 'Index Page', chunks: ['chunk-vendors', 'chunk-common', 'index'] } } }
The above is part of the sample code. For details, please refer to the official documentation or debug during the development process. .
Conclusion
After configuring the meta tag in uniapp, if the corresponding tag does not exist in the page source code, you need to manually add it in index.html; if it still does not take effect after packaging, you need to Confirm whether the configurations in manifest.json and vue.config.js are correct. I hope this article has solved your problem, and I also hope that uniapp can become more and more perfect and become a more stable and easy-to-use development tool.
The above is the detailed content of How to solve the problem that uniapp configuration meta does not take effect. For more information, please follow other related articles on the PHP Chinese website!

The article discusses debugging strategies for mobile and web platforms, highlighting tools like Android Studio, Xcode, and Chrome DevTools, and techniques for consistent results across OS and performance optimization.

The article discusses debugging tools and best practices for UniApp development, focusing on tools like HBuilderX, WeChat Developer Tools, and Chrome DevTools.

The article discusses end-to-end testing for UniApp applications across multiple platforms. It covers defining test scenarios, choosing tools like Appium and Cypress, setting up environments, writing and running tests, analyzing results, and integrat

The article discusses various testing types for UniApp applications, including unit, integration, functional, UI/UX, performance, cross-platform, and security testing. It also covers ensuring cross-platform compatibility and recommends tools like Jes

The article discusses common performance anti-patterns in UniApp development, such as excessive global data use and inefficient data binding, and offers strategies to identify and mitigate these issues for better app performance.

The article discusses using profiling tools to identify and resolve performance bottlenecks in UniApp, focusing on setup, data analysis, and optimization.

The article discusses strategies for optimizing network requests in UniApp, focusing on reducing latency, implementing caching, and using monitoring tools to enhance application performance.

The article discusses optimizing images in UniApp for better web performance through compression, responsive design, lazy loading, caching, and using WebP format.


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

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

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development 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.
