我已经尝试过这里的其他答案的例子,但我没有成功!
我创建了一个反应形式(即动态),我想在任何给定时间禁用某些字段.我的表格代码:
this.form = this._fb.group({
name: ['', Validators.required],
options: this._fb.array([])
});
const control = <FormArray>this.form.controls['options'];
control.push(this._fb.group({
value: ['']
}));
Run Code Online (Sandbox Code Playgroud)
我的HTML:
<div class='row' formArrayName="options">
<div *ngFor="let opt of form.controls.options.controls; let i=index">
<div [formGroupName]="i">
<select formArrayName="value">
<option></option>
<option>{{ opt.controls.value }}</option>
</select>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我减少了代码以方便.我想禁用select类型的字段.我试着做以下事情:
form = new FormGroup({
first: new FormControl({value: '', disabled: true}, Validators.required),
});
Run Code Online (Sandbox Code Playgroud)
不工作!有没有人有建议?
我需要在我的 reactjs 应用程序中集成 RTMP 播放器。我正在获取用于流式传输的 rtmpUrl 并尝试使用 react 播放器,但它不支持 rtmp url。
下面是我的代码,当我点击附加文本时,为什么它不起作用?
1:点击这是一个段落.
2:单击附加文本
3:必须显示红色的附加项目.
$(document).ready(function(){
$(".ali").click(function(){
$(this).parent().append("<b class='reza'>Appended text</b>");
});
$(".reza").click(function(){
$(this).append("<li style='color:red'>Appended item</li>");
});
});
Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<p><span class="ali"> This is a paragraph. </span> </p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我想知道哪种方法更好.假设我们有一种方法,例如,发送通知电子邮件.
void SendNotificaitonEmail();
Run Code Online (Sandbox Code Playgroud)
所以,我可以编辑我的SendNotificaitonEmail()
方法,所以它现在执行以下操作:
bool SendNotificationEmail(out string errorMessage)
{
try
{
// This is the code that handles the actual sending of the email.
// ..
}
catch(Exception ex)
{
errorMessage = ex.Message;
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
但就设计而言,这不是错吗?例如,errorMessage
变量与SendNotificationEmail()
方法的概念无关.此外,我应该为我的所有方法添加两个新变量 - 布尔值,声明方法的结果(true/false),以及包含错误消息的字符串1(如果有的话).
另一种方法是创建自定义异常并在调用第一个异常的其他方法中处理它们.
public void SendNotificaitonEmail()
{
try
{
// This is the code that handles the actual sending of the email.
// ..
if (somethingIsWrong == true)
{
throw new MyCustomException();
}
}
catch(Exception ex) …
Run Code Online (Sandbox Code Playgroud) Run Code Online (Sandbox Code Playgroud)export class A extends Component { constructor(props) { super(props) this.state = { collapse: false, divWidth: { width: 700, } } this.toggle = this.toggle.bind(this); } toggle() { this.setState(state => ({ collapse: !state.collapse })); } render() { const data = [{ name: 'Ayaan', age: 26 }, { name: 'Ahana', age: 22 }] const columns = [{ Header: 'Name', accessor: 'name' }, { Header: 'Age', accessor: 'age' }] return ( <div> <Button onClick={this.toggle} > Click Button </Button> <Modal isOpen={this.state.collapse} modalClassName={this.state.divWidth}> <ModalHeader>Welcome</ModalHeader> <ModalBody> <div …
reactjs ×2
angular ×1
c# ×1
exception ×1
handle ×1
java ×1
javascript ×1
react-player ×1
rtmp ×1