当我在JS文件中工作时,我得到了这些TypeScript错误VS Code.我有什么办法可以禁用它吗?我把它放在我的设置中并没有解决问题:
"typescript.validate.enable": false
Run Code Online (Sandbox Code Playgroud)
这里可以看到错误
所以我正在尝试设置 react-select 组件的输入字段的样式。不幸的是,字体系列被标准输入元素覆盖,因为样式被应用于包装器 div 而不是输入字段本身。
input: () => ({
fontFamily: `${theme.fonts.tabs.family} !important`,
fontWeight: theme.fonts.tabs.weight,
fontSize: 18,
color: theme.colors.secondary,
height: 24
}),
Run Code Online (Sandbox Code Playgroud)
我将如何在不使用类名的情况下更改 fontFamily?
我在输入字段上使用内置管道标题 - 在被动形式的用户名.只有当我在输入字段中输入时它才能正常工作,当我从该输入字段的浏览器建议中选择它时它就无法正常工作,即使我集中注意力也是如此.
app.component.ts
ngOnInit() {
this.signupForm = new FormGroup({
'userData': new FormGroup({
'username': new FormControl(null, [Validators.required, this.forbiddenNames.bind(this)]),
'email': new FormControl('abc@test.com', [Validators.required, Validators.email], this.forbiddenEmails)
}),
'gender': new FormControl('male'),
'hobbies': new FormArray([])
});
}
Run Code Online (Sandbox Code Playgroud)
app.component.html
<form [formGroup]="signupForm" (ngSubmit)="onSubmit()">
<div formGroupName="userData">
<div class="form-group">
<label for="username">Username</label>
<input
type="text"
id="username"
formControlName="username"
class="form-control"
[value]="signupForm.get('userData.username').value | titlecase">
<span *ngIf="signupForm.get('userData.username').errors['required']">
This field is required
</span>
</div>
...
</div>
<button class="btn btn-primary" type="submit">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)
当我打字时它工作正常
当我从浏览器选择中选择时它不起作用
虽然我从输入字段中聚焦它仍然是大写的.
@Haifeng Zhang这是我在问题中提到的场景,我在你的stackblitz演示中复制了
我正在开发一个项目,该项目将在 AWS 弹性 beantalk 中以编程方式创建环境。我正在使用适用于 PHP 版本 3 的 AWS 开发工具包。
我的脚本创建了环境。在 AWS 控制台中,环境显示为灰色并表示它已终止。查看事件显示“环境必须具有与之关联的实例配置文件”的错误。
我曾尝试使用两个不同用户的访问密钥和秘密。一位用户拥有 AmazonEC2FullAccess、IAMFullAccess 和 AWSElasticBeanstalkFullAccess 权限。另一个用户具有 AWSAdmin 权限。两个用户都可以从 AWS 控制台创建环境。
我不知道如何将实例配置文件与 SDK 中的环境相关联。我没有看到使用 createEnvironment 函数执行此操作的选项:createEnvironment 语法 在创建 ElasticBeanstalkClient 对象的实例时,我也没有看到执行此操作的方法。
我的代码如下。谢谢。
<?php
require 'vendor/autoload.php';
use Aws\ElasticBeanstalk\ElasticBeanstalkClient;
use Aws\Credentials\Credentials;
$key = '***key***';
$secret = '***secret***';
$credentials = new Credentials($key, $secret);
$ebClient = new ElasticBeanstalkClient([
'region' => 'us-east-2',
'version' => '2010-12-01',
'credentials' => $credentials
]);
$ebEnv = $ebClient->createEnvironment([
'ApplicationName' => 'app-from-sdk',
'EnvironmentName' => 'env-from-sdk-1',
'CNAMEPrefix' => 'sdk-test1',
'Description' => …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-php-sdk amazon-elastic-beanstalk aws-sdk
这是我的angular2代码.
模板
<div #picker class="slider">
<div class="slider-track">
<div #sliderSelectionEl class="slider-selection"></div>
<div #sliderHandle1 class="slider-handle"></div>
<div #sliderHandle2 class="slider-handle"></div>
</div>
<div #tooltipEl class="tooltip">
<div class="tooltip-arrow"></div>
<div #tooltipInner class="tooltip-inner"></div>
</div>
<input type="text" class="span2" value="" id="sl2"><br/>
</div>Run Code Online (Sandbox Code Playgroud)
零件
import {Component, OnInit, Input, ViewChild, ElementRef, Renderer} from '@angular/core';
export class SliderComponent implements OnInit {
@ViewChild('picker') picker: ElementRef;
constructor(private renderer: Renderer, private el: ElementRef) {
}
ngAfterViewInit() {
this.renderer.setElementClass(this.picker.nativeElement, 'slider-horizontal', true);
console.log(this.picker.nativeElement.offsetWidth);
console.log(this.picker.nativeElement.offsetHeight);
}
}
.slider-horizontal {
width: 210px;
height: 20px;
}Run Code Online (Sandbox Code Playgroud)
问题是每次加载的打印值都不同.我猜这个问题是由于浏览器还没有完成加载div.你知道这是什么解决方案吗?
我试图摆脱这个错误消息,但仍然没有成功.
Warning: A component is changing an uncontrolled input of type text to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component.
Run Code Online (Sandbox Code Playgroud)
还有链接到Facebook页面,但我仍然不知道如何弄明白.
class EditItem extends Component {
constructor(props) {
super(props);
this.state = {items: ''};
this.addItemService = new ItemService();
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
componentDidMount(){
axios.get('http://localhost:3005/items/edit/'+this.props.match.params.id)
.then(response => {
this.setState({ items: response.data });
})
.catch(function (error) {
console.log(error); …Run Code Online (Sandbox Code Playgroud) 我正在尝试将 Cognito 身份验证合并到我的基于 React 的项目中。我的代码基于 NPM 页面中给出的示例。这是它的样子:
var authenticationData = {
Username : 'username',
Password : 'password',
};
var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails(authenticationData);
var poolData = {
UserPoolId : '...', // Your user pool id here
ClientId : '...' // Your client id here
};
var userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
var userData = {
Username : 'username',
Pool : userPool
};
var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
console.log('Successfully logged!');
}
});
},
onFailure: function(err) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 formarray 中的 formcontrol 上实现材料自动更正,但是当我尝试访问 ts 文件中的 formcontrol 时,它无法访问它。谁能帮帮我吗。
html 文件:
<div formArrayName="applicants">
<div *ngFor="let applicant of appForm.controls.applicants.controls; let i=index; let last = last">
<div [formGroupName]="i">
<div class="row">
<label for="applicant_short_name" class="col-sm-3 form-control-label">Applicant {{i+1}}</label>
<div class="col-sm-7">
<div class="form-group">
<!-- <input type="text" formControlName="applicant_short_name" class="form-control" id="inputFirstName" placeholder="Applicant"> -->
<!-- <mat-form-field > -->
<input type="text" class="form-control" id="inputFirstName" placeholder="Applicant" [matAutocomplete]="auto" [formControlName]="applicant_short_name">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let state of filteredNames | async | slice:0:3" [value]="name">
<span>{{ name }}</span>
</mat-option>
</mat-autocomplete>
<!-- </mat-form-field> -->
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
.ts 文件: …
是否可以转换回ElementRef组件。
我有一种情况,我手上有nativeElement,我需要将它转换为组件。看一下console.log,我想解压出来name,可以投回去吗?谢谢
https://stackblitz.com/edit/angular-8aoq7f?file=src%2Fapp%2Fapp.component.ts
@Component({
selector: 'my-app',
template: `<sub-component [name]="'test'"></sub-component>`,
})
export class AppComponent {
constructor(private ref : ElementRef){
console.log((<SubComponent>this.ref.nativeElement).name); //<--- .name is undefined
}
}
@Component({
selector: 'sub-component',
template: `<div>{{name}}</div>`,
})
export class SubComponent {
@Input() name : string
}
Run Code Online (Sandbox Code Playgroud) angular ×4
reactjs ×3
aws-sdk ×2
javascript ×2
typescript ×2
angular-pipe ×1
angular6 ×1
aws-cognito ×1
aws-php-sdk ×1
form-control ×1
html ×1
react-select ×1