html - 子组件未在 iOS 上显示
问题描述
我正在尝试为桌面和移动设备创建一个基本的 Web 应用程序,但我遇到了一个问题,即在我的主组件中使用我的子组件的根选择器不会显示子组件并使其下方的元素消失。
即使子组件中的 html 是空白的,使用子组件选择器仍然会导致问题,但是如果我完全删除选择器,其他一切看起来都很好。
这是我的代码:
.menu {
float: left;
width: 20%;
text-align: center;
}
.main {
float: left;
width: 60%;
text-align: center;
padding: 0 20px;
}
.right {
float: left;
width: 20%;
padding: 15px;
margin-top: 7px;
text-align: center;
}
@media only screen and (max-width:620px) {
.menu,
.main,
.right {
width: 100%;
}
}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<div style="overflow:auto">
<div class="menu">
<h2>Text</h2>
<p>Text</p>
</div>
<div class="main">
<button>Test</button>
<child-component></child-component>
</div>
<div class="right">
<h2>Text</h2>
<p>Text</p>
</div>
</div>
这是子组件(无 CSS):
<p>Click the button</p>
<button [hidden]="started" (click)="start()">Start</button>
<button [hidden]="!started" (click)="stop()">Stop</button>
<button [hidden]="!canreset" (click)="reset()">Reset</button>
<p>Your message: {{display}}</p>
我查看了其他帖子并尝试在子组件上设置 ViewEncapsulation.None,但这似乎不起作用。
解决方案
推荐阅读
- java - 使用 Set 字符串在 sqlite 上运行查询
- google-colaboratory - 当我开始训练我的模型时,YOLO 暗网冻结
- reactjs - 在动作创建者中访问 useReducer 状态
- prolog - 我应该通过抛出实例化错误来强制执行模式声明吗?
- gradle-kotlin-dsl - 如何使用 Kotlin DSL 引用 gradle.properties 中设置的 gradle 配置?
- android - 如何通过 DialogFragment 正确传递视图外的点击?
- azure-devops - Azure Devops:模板使用序列类型参数生成作业和阶段
- sql - 3套配对排除标准
- python - 如果内部函数已经有其同名的变量Python,如何从内部函数访问封闭函数中的非局部变量
- scheme - 如何解析 Racket 中的日期字符串?