uniapp 在static/index.html中添加全局样式

前言

在static/index.html中添加全局样式

css 复制代码
<style>
	div {
		background-color: #ccc;
	}
</style>

static/index.html源码:

html 复制代码
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		  <meta name="renderer" content="webkit">
		<title><%= htmlWebpackPlugin.options.title %></title>
    <link rel="shortcut icon" type="image/x-icon" href="<%= BASE_URL %>static/favicon.ico">
		<script>
			var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
			document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')
		</script>
		<link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
		<style>
			div {
				background-color: #ccc;
			}
		</style>
	</head>
	<body>
		<noscript>
			<strong>本站点必须要开启JavaScript才能运行.</strong>
		</noscript>
		<div id="app"></div>
</html>

编译后的源码:

在static/index.html中添加全局样式的特点

  • 编译后的源码中,css未被加上了属性选择器
  • 对所有页面生效
  • 全局有效
相关推荐
叱咤少帅(少帅)2 天前
Uniapp开发pc端,小程序和APK
小程序·uni-app
2501_915918413 天前
iOS性能测试工具 Instruments、Keymob的使用方法 不局限 FPS
android·ios·小程序·https·uni-app·iphone·webview
2501_915918413 天前
iOS 混淆流程 提升 IPA 分析难度 实现 IPA 深度加固
android·ios·小程序·https·uni-app·iphone·webview
前端 贾公子3 天前
解决uni-app 输入框,键盘弹起时页面整体上移问题
前端·vue.js·uni-app
Muchen灬3 天前
【uniapp】(5) 创建gitee仓库并推送源码
gitee·uni-app
Muchen灬3 天前
【uniapp】(6) uniapp中使用vuex
uni-app
2501_915909063 天前
React Native 上架 App Store:项目运行与审核构建的流程
android·ios·小程序·https·uni-app·iphone·webview
李庆政3703 天前
uniapp+unicloud打包部署微信小程序
微信小程序·小程序·uni-app
2501_915909063 天前
苹果 Safari 浏览器抓包 页面刷新后的请求分析
android·前端·ios·小程序·uni-app·iphone·safari