- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Material UI 的 Switch 组件,我想在其中添加文本。我还需要把它做成正方形。
如何在 Switch 组件中添加文本。它应该在选择时打开,在默认时关闭。我在 Formcontrol 中以 reactjs 形式使用 Material UI 的 Switch。
<FormControlLabel
label="Private ? "
labelPlacement="start"
control={
<Switch
checked={this.state.checked}
onChange={this.handleChange}
color='primary'
/>
}
/>
最佳答案
下面是一个示例,说明如何根据 Switch 的状态以及方形 Switch 的样式更改文本:
import React from "react";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import Switch from "@material-ui/core/Switch";
import { withStyles } from "@material-ui/core/styles";
const styles = {
// use "icon" instead of "thumb" in v3
thumb: {
borderRadius: 0
}
};
class SwitchLabels extends React.Component {
state = {
checked: true
};
handleChange = event => {
this.setState({ checked: event.target.checked });
};
render() {
return (
<FormControlLabel
control={
<Switch
classes={this.props.classes}
checked={this.state.checked}
onChange={this.handleChange}
value="checked"
color="primary"
/>
}
labelPlacement="start"
label={this.state.checked ? "On" : "Off"}
/>
);
}
}
export default withStyles(styles)(SwitchLabels);
关于reactjs - 将文本添加到 Switch formcontrol 并使用 material ui 在 toggle 中更改它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56128013/
根据 the documentation , NLog 提供了一个 FormControl 目标,它将日志消息写入 Windows 窗体上控件的 Text 属性。但是,当我将 FormControl
以下是我的指令: restrict: 'E', scope: { }, templateUrl: 'directives/my.directive.html', link: function(scop
有没有办法在 Angular2+ 中声明表单模型时向 FormControl 添加任意元数据? 类似于: // In this fake example, {foo: 'bar'} is the me
如何在输入 FormControl 中显示一些不等于此 FormControl 值的文本? 例如,从服务器获取一些对象 - {id: 1, name: "Name1"} ,并设置 value Form
我正在研究 Angular Reactive 表单。这是我的组件类代码: ngOnInit(){ this.reviewForm = this.fb.group({
FormControl 在处理指令时遇到困难... 我正在尝试在我的输入字段中实现自动完成功能。我正在使用以下 Angular Material 指南,我逐字复制并粘贴了他们的 typescript
我正在使用 Angular 8 和 Reactive Forms。 在我的模板中,我有如下代码: 想法是,如果 validationError 为“truthy”,则在输入元素中添加红色边框。 无法
有没有办法检查是否需要控制? 当我实现一个专用的表单字段组件时出现了问题,该组件接受 FormControl 并且不仅有 输入 而且还有验证错误。由于某些字段是必需的,因此最好让用户知道 * 是否需要
FormControl 在处理指令时遇到困难... 我正在尝试在我的输入字段中实现自动完成功能。我正在使用以下 Angular Material 指南,我逐字复制并粘贴了他们的 typescript
我正在使用 Angular 8 和 Reactive Forms。 在我的模板中,我有如下代码: 想法是,如果 validationError 为“truthy”,则在输入元素中添加红色边框。 无法
我有一系列的项目。每个项目将通过使用 ng-repeat 和 ng-form 动态关联到一个表单。 ... 然后我就有可能创建新项目。但是当我这样做时,我希望他们的新形式变得变脏。 ADD
我想通过自定义指令将验证器动态添加到我的 FormControl。 @Directive({ selector: "[idNumber]", }) export class IdNumberD
我正在使用 Sematinc-UI 和 Angular2 ReactiveFormsModule 表单,我想使用 [formControl] 来选择多个。 如果我使用 select 它可以正常工作:
我现在已经根据一些逻辑从一个大型 FormGroup 中过滤掉了几个 FormControl - 我想知道如何合并/组合这些选定的 FormControl 并且只有一个订阅.. 我查看了 RxJS 文
我有 3 个字段与表单链接,类型为数字,当我修改字段 A 时,它会修改字段 B 和 C,当我修改字段 B 时,它会修改字段 A 和 C,当我修改字段 C 时,它会修改字段 A 和B相应地。 我的组件如
我有表单数组 FormGroup; let forms = [this.form1, this.form2]; 每个表单都有几个控件:FormControl。 如何向 FormControl 添加额外
我有一个使用自定义组件作为输入的表单,它接收一个 ControlName。当我在组件中键入内容时,它不会更新“错误”属性。 app-pf-input-text.ts: import { Compone
我讨论了表单应该如何与同事合作,我们对后端驱动的输入字段应该如何响应用户输入有不同的想法。 此讨论基于 Angular's definition of pristine "pristine" mean
我有包含 FormArray 的 FormGroup。由系统生成的 FormArray 中的每个 FormControls 如下所示: staffs: FormArray = { staffs
我使用的框架(Angular 7)。 我想像这样为 FormControl 设置一些类型。 startDate: FormControl; endDate: FormControl;
我是一名优秀的程序员,十分优秀!