当前位置:网站首页>父组件加scoped有时也会影响子组件
父组件加scoped有时也会影响子组件
2022-07-17 05:05:00 【K I S】
父组件加scoped有时也会影响子组件
今天在写vue组件时发现当父组件添加了scoped时,在不使用/deep/的情况下也会影响到子组件的样式,具体情况如下。
父组件
<template> <div id="app"> <div class="app_top"> <h1>Vue-练习</h1> <hr> </div> <!--子组件Left--> <Left></Left> </div> </template> <style lang="less" scoped> .content_left{ text-align: center; } </style>子组件Left
<template> <div class="content_left"> Myleft </div> </template>本以为父组件在没有使用/deep/时子组件中的"Myleft"不会居中,但是事实是子组件中的"Myleft"居中显示了。

原因
在浏览器调试发现,当父组件添加scoped时不仅会给自己本身的元素添加"data-v-xxx"的自定义属性,同时也会给其子组件的元素加上"data-v-xxx"的自定义属性。


完结!!
边栏推荐
- 简单快速建立pytorch环境YOLOv5目标检测 模型跑起来(超简单)
- 学习C语言第7天
- es6新增-运算符的扩展
- Ucharts chart, pie chart, bar chart and line chart are used in uniapp
- Wechat applet wx Setclipboarddata copy text
- 【C语言—零基础第十课】数组王国奇遇记
- Infinite classification
- uniapp中使用ucharts图表,饼状图,柱状图,折线图
- H5如何获取内网IP和公网IP
- PCA feature dimensionality reduction of machine learning + case practice
猜你喜欢

Internship project 3- change owner

The code of yolov5 model for pest identification in Title A of the 10th Teddy cup data mining challenge (has been run through, original works, continuously updated)

MySQL optimization

uniapp 使用uview实现折叠面板

使用Echars实现水滴状、环形图、分割图、堆叠、组织架构图、地图轮廓等图表

Baidu map realizes thermal map

vscode终端无法使用解决的办法

es6新增-运算符的扩展

实习项目1-个性化主页配置

mysql数据库实验实训6,数据视图(详细)
随机推荐
决策树原理和案例应用-泰坦尼克号生存预测
微信小程序获取年月日周及早上、中午、晚上
Using JS to realize the second level menu of anjuke and the full version (demonstration of precautions and problem points)
学习C语言第8天
学习C语言第7天
机器学习之特征提取(类别特征进行数值化、离散化、文本特征进行数值化)
Feature extraction of machine learning (digitization and discretization of category features and digitization of text features)
哨兵二号轨道数据下载
Mysql database experiment training 6, data view (detailed)
H5如何获取内网IP和公网IP
Installation and fast use of Mongo DB stand-alone version
泰迪杯A题完整版 优化更新(4/23)
6S参数
学习C语言的第6天
The principle and local storage of the throttle valve of the rotation chart are summarized
IDL MODIS 生成查找表
uniapp 使用uview实现折叠面板
Two methods of rotation chart and automatic rotation
Pygame:外星人入侵
Wechat applet wx Setclipboarddata copy text