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未被加上了属性选择器
  • 对所有页面生效
  • 全局有效
相关推荐
Amewin15 小时前
在vue3+uniapp+vite中挂载全局属性方法
javascript·vue.js·uni-app
2501_915106321 天前
App HTTPS 抓包 工程化排查与工具组合实战
网络协议·ios·小程序·https·uni-app·php·iphone
dcloud_jibinbin1 天前
【uniapp】小程序体积优化,分包异步化
前端·vue.js·webpack·性能优化·微信小程序·uni-app
2501_916008891 天前
金融类 App 加密加固方法,多工具组合的工程化实践(金融级别/IPA 加固/无源码落地/Ipa Guard + 流水线)
android·ios·金融·小程序·uni-app·iphone·webview
2501_915921431 天前
Fastlane 结合 开心上架(Appuploader)命令行版本实现跨平台上传发布 iOS App 免 Mac 自动化上架实战全解析
android·macos·ios·小程序·uni-app·自动化·iphone
游戏开发爱好者81 天前
iOS 上架要求全解析,App Store 审核标准、开发者准备事项与开心上架(Appuploader)跨平台免 Mac 实战指南
android·macos·ios·小程序·uni-app·iphone·webview
00后程序员张1 天前
混淆 iOS 类名与变量名的实战指南,多工具组合把混淆做成工程能力(混淆 iOS 类名变量名/IPA 成品混淆Ipa/Guard CLI 实操)
android·ios·小程序·https·uni-app·iphone·webview
2501_916007471 天前
iOS文件管理工具深度剖析,从系统沙盒到跨平台文件操作的多工具协同实践
android·macos·ios·小程序·uni-app·cocoa·iphone
shykevin1 天前
uni-app x开发商城系统,扩展组件uni-ui实现底部商品导航
uni-app
QuantumLeap丶1 天前
《uni-app跨平台开发完全指南》- 05 - 基础组件使用
vue.js·微信小程序·uni-app