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未被加上了属性选择器
  • 对所有页面生效
  • 全局有效
相关推荐
游戏开发爱好者811 小时前
抓包工具有哪些?代理抓包、数据流抓包、拦截转发工具
android·ios·小程序·https·uni-app·iphone·webview
郑州光合科技余经理15 小时前
技术解析:如何打造适应多国市场的海外跑腿平台
java·开发语言·javascript·mysql·spring cloud·uni-app·php
前端 贾公子15 小时前
uniapp之实现拖拽排序
uni-app
一室易安16 小时前
uniapp vue3 小程序中 手写模仿京东淘宝加入购物车红点曲线飞入样式效果 简化版代码
小程序·uni-app
00后程序员张16 小时前
混合 App 怎么加密?分析混合架构下常见的安全风险
android·安全·小程序·https·uni-app·iphone·webview
2501_9159214318 小时前
Flutter App 到底该怎么测试?如何在 iOS 上进行测试
android·flutter·ios·小程序·uni-app·cocoa·iphone
2501_9159090618 小时前
如何在 Windows 上上架 iOS App,分析上架流程哪些是不用mac的
android·macos·ios·小程序·uni-app·iphone·webview
2501_9159214319 小时前
分析 iOS 描述文件创建与管理中常见的问题
android·ios·小程序·https·uni-app·iphone·webview
Aftery的博客19 小时前
Uniapp-vue实现语言功能切换(多语言)
javascript·vue.js·uni-app
我这一生如履薄冰~2 天前
uni-app 项目配置代理踩坑
uni-app