vue在父组件中给子组件内的结构设置样式

父组件写css时,样式选择器中加上 /deep/或者 >>> 这两个标记就可以添加到到子组件结构的样式中了。
举例:

父组件

<div>
	<searchForm class="searchFormStyle"></searchForm>
<div>
<style>
	.searchFormStyle /deep/ .insideStyle{
		background-color: yellow;
	}
</style>

子组件searchForm内

<tmeplate>
	<div class="container">
		<input type="text" class="insideStyle">
		<button>搜索</button>
	</div>
</template>

另外,要注意的是,据说,在vue-loader 11.2.0之后才支持。

猜你喜欢

转载自blog.csdn.net/qq_39852145/article/details/84543135