我有一个已在生产服务器中成功部署的域。
但是,每当我打开它时,地址栏中就会显示一个Install app: Create React app sample
。
有什么办法可以删除它。 我应该更改我的代码吗? 这里有什么建议吗?
// Client package.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.19.2",
"bootstrap": "^4.4.1",
"bootstrap-less": "^3.3.8",
"moment": "^2.24.0",
"node-sass": "^4.13.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"redux-thunk": "^2.3.0",
"uuid": "^7.0.3"
},
"scripts": {
"start": "react-scripts start",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
],
"development": [
"last 1 chrome version",
]
},
"proxy": "http://localhost:5000"
}
// manifest.json
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
答案 0 :(得分:3)
您需要更改manifest.json文件,您可能会在由create-react-app创建的公共文件夹中找到它。
manifest.json文件由serviceWorker使用,以允许用户将您的Web应用程序安装为应用程序,您可以跳过short_name属性,但应提供适当的名称。但同时跳过这两个选项不会导致应用程序功能出现任何问题,在这种情况下,浏览器将为您的应用程序使用默认名称(即,无标题)。
在我的建议下,您应同时提供short_name
和name
属性。
在那里
{
"short_name": "React App",
"name": "Create React App Sample", // you need to change this
"icons": [
{
"src": "favicon.ico",
"sizes": "192x192",
"type": "image/png"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}