我在这里有脚本,ng-pattern工作正常,因为只有输入匹配模式后,才会在输出中显示scope.subnet.但是如果ng-pattern不匹配,ng-show不会显示任何错误
<body ng-contoller="myConfigGenCtr">
<form novalidate name="myForm">
<div class="form-group">
<label for="hostname">Firewall hostname</label>
<input type="text" ng-model="hostname" class="form-control" id="hostname">
</div>
<div class="form-group">
<label for="subnet">Firewall subnet</label>
<input type="text" ng-model="subnet" class="form-control" id="subnet"
required ng-pattern="/^(?:[0-9]{1,3}\.){3}/" >
<div class="custom-error" ng-show="myForm.subnet.$error.pattern">
Not a valid subnet, should be i.e. 10.x.y. (3 bytes only)</div>
</div>
</form>
<div>Output: {{subnet}}</div>
</body>
Run Code Online (Sandbox Code Playgroud) 我有基于arm的busybox(嵌入式Linux)与有限的二进制文件如何http发布或放置而不使用curl?
我有MyComponent使用setData()在state中写入数据,getData()用于读取状态.这是React的最佳实践吗?它对我来说很好,但不确定我做的是最简单的方法,请建议
class MyComponent extends Component {
constructor(props) {
super(props);
this.state = {
data: []
};
}
setData(){
this.setState({data:"123"});
}
getData() {
console.log(this.state.data); // 123 OK !!!
}
componentDidMount() {
this.setData();
}
componentDidUpdate() {
this.getData();
}
render() {
return (
<div>
{this.state.data} // 123 OK !!!
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud) 我有例子play.golang.org/p/Y1KX-t5Sj9我在struct User上定义方法Modify()
type User struct {
Name string
Age int
}
func (u *User) Modify() {
*u = User{Name: "Paul"}
}
Run Code Online (Sandbox Code Playgroud)
在main()中我定义了struct literal &User {Name:"Leto",Age:11}然后调用u.Modify().这导致打印' 保罗0 '我喜欢结构字段名称已更改,但保持Age字段的正确方法是什么?
我有 2 个 KQL 查询,我想将它们组合起来以将两行显示为一个结果。不仅仅是第一次查询的结果,然后是第二次查询的结果:
R_CL
| where isnotempty(SrcIP_s)
| project Message
| take 1;
R_CL
| where isempty(SrcIP_s)
| project Message
| take 1
Run Code Online (Sandbox Code Playgroud)
请参阅下面的示例R_L。我想看到 2 行作为结果,一个 SrcIP_s 不为空,第二个 SrcIP_s 为空(在这种情况下,它总是相同的)
let R_CL = datatable ( SrcIP_s:string, Message:string)
["1.1.1.1" ,"one",
"" ,"two",
"2.2.2.2","three",
"3.3.3.3","four"];
R_CL
| project SrcIP_s, Message
Run Code Online (Sandbox Code Playgroud) 在下面的代码中,与forEach循环一起使用的回调函数遍历返回的结果。forEach循环中的变量“错误”和回调中的“错误”是否相同?
session.getAll(options, function (error, varbinds) {
varbinds.forEach(function (vb) {
if (error)
console.log('getALL Fail ');
else
console.log(vb.value);
});
});
Run Code Online (Sandbox Code Playgroud) 我有功能组件GetWeather,我希望将GetLocation函数的结果作为道具传递,基于GetWetaher将执行某些操作,即另一个获取请求(在下面的示例中,它仅渲染其道具).我认为它必须在ComponentDidMount内部发生,不知道如何做到这一点
function GetLocation() {
axios.get('http://ipinfo.io')
.then((res) => {
return res.data.loc;
})
}
function GetWeather(props) {
//more code here, including another get request, based on props
return <h1>Location: {props.location}</h1>;
}
class LocalWeather extends Component {
componentDidMount() {
//???
}
render() {
return (
<div >
<GetWeather location={GetLocation}/> //???
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud)
更新:所以根据Damian的建议,下面的内容对我有用
function GetWeather(props) {
return <h3>Location: {props.location}</h3>;
}
class LocalWeather extends Component {
constructor(props) {
super(props);
this.state = {
location: []
};
}
getLocation() {
axios.get('http://ipinfo.io')
.then((res) => …Run Code Online (Sandbox Code Playgroud) 我在下面有 xml 字符串,并尝试在每个条目标签的标签域、接收时间、序列和序列号之间打印文本。
xml="""
<response status="success" code="19"><result><msg><line>query job enqueued with jobid 19032</line></msg><job>19032</job></result></response>
19032
<response status="success"><result>
<job>
<tenq>14:10:09</tenq>
<tdeq>14:10:09</tdeq>
<tlast>19:00:00</tlast>
<status>ACT</status>
<id>19032</id>
<cached-logs>64</cached-logs>
</job>
<log>
<logs count="20" progress="29">
<entry logid="2473601">
<domain>1</domain>
<receive_time>2017/11/26 14:10:08</receive_time>
<serial>007901004140</serial>
<seqno>10156449120</seqno>
</entry>
<entry logid="2473601">
<domain>1</domain>
<receive_time>2017/11/26 14:10:08</receive_time>
<serial>007901004140</serial>
<seqno>10156449120</seqno>
</entry>
</logs>
</log>
</result></response>
"""
Run Code Online (Sandbox Code Playgroud)
使用 xml.etree.ElementTree。为了获得域标签之间的内容,我正在尝试node.attrib.get('domain')或node.get('domain') ..请告知
import xml.etree.ElementTree as ET
tree = ET.fromstring(xml)
for node in tree.iter('entry'):
print node
Run Code Online (Sandbox Code Playgroud)
它也可以是其他 python 库,不必是 xml.etree。我不想盲目地在标签之间打印文本,我需要打印标签名称后跟文本,例如:
domain: 1 …Run Code Online (Sandbox Code Playgroud) 我定义了两个结构类型Type1和Type2
type Type1 struct {
A1,B1,C1 string
}
type Type2 struct {
A1,B1 string
}
Run Code Online (Sandbox Code Playgroud)
将它们嵌入到struct type Supertype中
type Supertype struct {
Type1
Type2
}
Run Code Online (Sandbox Code Playgroud)
然后使用方法Send定义接口Sender,以便同时用于Type1和Type2
type Sender interface {
Send()
}
Run Code Online (Sandbox Code Playgroud)
最后,我定义了func,我想引用Type1和Type2字段
func (p Supertype) Send() {
..
p.A1 = "foo"
..
}
Run Code Online (Sandbox Code Playgroud)
当然得到'模棱两可的选择器p.A1'错误.如何使用方法发送两种结构类型Type1和Type2?有类似的问题两个不同类型如何在golang中使用接口实现相同的方法?但我不认为它适用于我的情况
仍然无法在 Terraform v0.12.6 中使用变量提供程序吗?在 *.tfvars 中,我列出了变量 供应商
supplier = ["azurerm.core-prod","azurerm.core-nonprod"]
Run Code Online (Sandbox Code Playgroud)
和 provider.tf 中定义的提供者:
provider "azurerm" {
...
alias = "core-prod"
}
provider "azurerm" {
...
alias = "core-nonprod"
Run Code Online (Sandbox Code Playgroud)
然后我想在 *.tf 中引用它。下面的例子是“数据”,但同样适用于“资源”
data "azurerm_public_ip" "pip" {
count = "${var.count}"
....
provider = "${var.supplier[count.index]}"
}
Run Code Online (Sandbox Code Playgroud)
什么是解决方法?错误:无效的提供者配置引用,显示提供者参数需要提供者类型名称,可选后跟一个句点,然后是配置别名。