我试图了解 Terraform 中的版本是如何工作的。
例如Terraform 文档中的这个演示:
terraform {
required_providers {
mycloud = {
source = "mycorp/mycloud"
version = "~> 1.0"
configuration_aliases = [ mycloud.alternate ]
}
}
}
Run Code Online (Sandbox Code Playgroud)
我没有在与版本相关的官方 Terraform 文档中找到任何相关内容,尤其是此~>. 我错过了吗?
~>terraform required_providers 版本中的含义是什么?有文件吗?谢谢
我正在使用 Angular 2。我尝试从表格单元格中检索数据。有没有 Angular 2 的方法来做到这一点?
我试图这样做,但我得到了undefined价值。
<table>
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td (click)="getValue($event)">John</td>
<td>Doe</td>
<td>john@example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary@example.com</td>
</tr>
</tbody>
</table>
getValue(event:any) {
let value = event.target.value;
console.log("value", value);
}
Run Code Online (Sandbox Code Playgroud) 有孩子路由器时怎么回到最后一页?
请参阅代码中的注释以获取详细信息 谢谢
export class OneProductComponent {
prevUrlPath:string = '';
constructor(private _router: Router) {}
routerOnActivate(next:ComponentInstruction, prev:ComponentInstruction) {
this.prevUrlPath = prev.urlPath;
}
goBack() {
// I have to manually add "products/" here, but if I need
// go back to root home page. Then I shouldn't add "products/" here.
// Is there a smart way to to this?
this._router.navigateByUrl(`products/${this.prevUrlPath}`);
}
}
Run Code Online (Sandbox Code Playgroud) 当我将 a 转换为string时ObjectId,我使用
import * as mongoose from 'mongoose';
const objId = mongoose.Types.ObjectId(strId);
Run Code Online (Sandbox Code Playgroud)
它在TypeScript 1.x 中运行良好,更新到TypeScript 2.x 后,出现错误:
错误 TS2348:“typeof ObjectID”类型的值不可调用。您的意思是包含“新”吗?
我该如何解决?谢谢
我正在使用TypeScript 2.x和lodash.
我用的时候
console.log(_.reduce([1, 2], (result, n) => result + n)); // 3
Run Code Online (Sandbox Code Playgroud)
它给了我错误:
错误TS2365:运算符"+"无法应用于类型"{}"和"数字".
我正在使用ngrx.我收到了错误
无法读取未定义的属性"类型"
这是我的代码的一部分:
@Effect() foo$ = this.actions$
.ofType(Actions.FOO)
.withLatestFrom(this.store, (action, state) => ({ action, state }))
.map(({ action, state }) => {
if (state.foo.isCool) {
return { type: Actions.BAR };
}
});
Run Code Online (Sandbox Code Playgroud) 我正在使用 Draft.js 插件Resizeable。
我正在尝试使用原始长宽比调整图像大小。
但是,对于下面的代码,当我使用鼠标按图像的下边缘调整大小时,光标发生了变化,但无法调整大小。它仅在左侧和右侧边缘效果良好。
const resizeablePlugin = createResizeablePlugin({
vertical: 'relative',
horizontal: 'relative'
});
Run Code Online (Sandbox Code Playgroud)
看了源码,还是没明白是什么原因造成的。
我正在使用mailchimp-api-v3提交表单。
该列表只有三个字段,分别是FNAME、EMAIL、 和COMPANY。
const Mailchimp = require('mailchimp-api-v3');
const mailchimp = new Mailchimp(myMailchimpAPI);
mailchimp.post(`/lists/${myListId}/members`, {
FNAME: 'Jack',
EMAIL: 'jack@example.com',
COMPANY: 'Apple'
})
.then(res => console.log(res))
.catch(err => console.log(err));
Run Code Online (Sandbox Code Playgroud)
这给了我错误:
[ { field: 'email_address', message: '该值不应为空。' } ] }
我想在 Angular 2 中重用这个 D3.js 组件。
@Component({
selector: 'child-cmp',
template: `
<div>
<svg class="chart"></svg>
</div>
`
})
export class ChildCmp {
ngOnInit() {
let chart = d3.select(".chart")
.append("g")
.append("rect")
.attr("width", 50)
.attr("height", 100);
}
}
Run Code Online (Sandbox Code Playgroud)
http://plnkr.co/edit/PnJfFJ7sOZIxehs2LHNh?p=preview
但是,您可以在此演示中看到,两个矩形不能很好地显示在一起。
如何正确重用这些 D3.js 组件?谢谢
我正在尝试将图像插入到Draft.js编辑器中.
根据我的理解,我需要更新实体mergeData和阻止mergeBlockData.(我不确定)
现在我想mergeBlockData用来插入一个块.
Run Code Online (Sandbox Code Playgroud)mergeBlockData( contentState: ContentState, selectionState: SelectionState, blockData: Map<any, any> ): ContentState
请阅读代码中的评论.
import { Map } from 'immutable';
const selection = this.state.editorState.getSelection();
const contentState = this.state.editorState.getCurrentContent();
console.log(convertToRaw(contentState)); // for example, I have 3 blocks
const blockData = Map({ ov72: { // here how to generate a random valid key?
"key": "ov72",
"text": " ",
"type": "atomic",
"depth": 0,
"inlineStyleRanges": [],
"entityRanges": [{
"offset": 0,
"length": 1,
"key": 1
}],
"data": {}
}}); …Run Code Online (Sandbox Code Playgroud)