Skip to main content

嵌套 <style> 元素

每个组件只能有一个顶层 <style> 标签。

¥There can only be one top-level <style> tag per component.

但是,可以将 <style> 标记嵌套在其他元素或逻辑块中。

¥However, it is possible to have a <style> tag nested inside other elements or logic blocks.

在这种情况下,<style> 标签将按原样插入 DOM;不会对 <style> 标签进行范围界定或处理。

¥In that case, the <style> tag will be inserted as-is into the DOM; no scoping or processing will be done on the <style> tag.

<div>
	<style>
		/* this style tag will be inserted as-is */
		div {
			/* this will apply to all `<div>` elements in the DOM */
			color: red;
		}
	</style>
</div>