我有垫选择下拉列表如下
<mat-form-field>
<mat-label>Gender</mat-label>
<mat-select id="gender" required formControlName="gender">
<mat-option id="Male" value="male"> Male </mat-option>
<mat-option value="female"> Female </mat-option>
</mat-select>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用 Cypress 从该领域选择男性或女性。
cy.get('mat-select').click().select('Male')
Run Code Online (Sandbox Code Playgroud)
使用上面的代码,我收到以下错误:
CypressError: cy.select() can only be called on a <select>. Your subject is a: <mat-select>
Run Code Online (Sandbox Code Playgroud)
我需要一些帮助来解决这个问题,谢谢。
对我有用的代码。
cy.get('#gender').click().then(() => {
cy.get('#male').click()
})
Run Code Online (Sandbox Code Playgroud) 我想检查我创建的登录屏幕中是否存在文本“您必须输入一个值”(附有屏幕截图)。当用户触摸输入字段,然后单击不同的字段或区域而不输入任何内容时,就会出现这种情况。所以我尝试用 cypress 测试它,但它说
".type() will not accept an empty string"
Run Code Online (Sandbox Code Playgroud)
柏:
it('Should display You must enter a value if user does not type anything', () => {
cy.get('#username').type('')
cy.contains('You must enter a value')
})
Run Code Online (Sandbox Code Playgroud)
我需要帮助来解决这个问题,谢谢。
我需要帮助将路线添加到角度树。
HTML代码:
<mat-tree [dataSource]="dataSource" class="tree-container" [treeControl]="treeControl">
<mat-tree-node class="btnLinks" *matTreeNodeDef="let node" matTreeNodePadding>
<button mat-icon-button disabled></button>
{{node.name}}
</mat-tree-node>
<mat-tree-node class="btnLinks" *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding>
<button mat-icon-button matTreeNodeToggle
[attr.aria-label]="'toggle ' + node.name">
<mat-icon class="mat-icon-rtl-mirror">
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
</mat-icon>
</button>
{{node.name}}
</mat-tree-node>
</mat-tree>
Run Code Online (Sandbox Code Playgroud)
.Ts 文件
interface ProfileList {
name: string;
children?: ProfileList[];
}
const PROFILE_DATA: ProfileList[] = [
{
name: 'General',
},
{
name: 'Degrees',
},
];
/** Flat node with expandable and level information */
interface TreeFlatNode {
expandable: boolean;
name: …Run Code Online (Sandbox Code Playgroud) 我已经按预期获得了模态,但我无法使背景变暗。
我也尝试过,backdropColor = {'green'} backdropOpacity = {1}但背景仍然存在。我需要这方面的帮助。下面是我的代码:
import Modal from "react-native-modal";
<View
style={styles.MainContainer}>
<Modal
backdropColor={'green'}
backdropOpacity= {1}
animationType={"slide"}
visible={this.state.ModalVisibleStatus}
onRequestClose={ ()=>{ this.ShowModalFunction(!this.state.ModalVisibleStatus)}}>
<View style={{ flex:1, justifyContent: 'center', alignItems: 'center' }}>
<View style={styles.ModalInsideView}>
<Text
style={styles.TextStyle}>
Enter the Number of Tickets to be Printed.
</Text>
<NumberSpinner
packageCount={this.state.tickets} min={0} max={20}
onChange={this.ticketsCount}
/>
<Button
title="Print Tickets"
onPress={() => { this.ShowModalFunction(!this.state.ModalVisibleStatus)}}/>
</View>
</View>
</Modal>
Run Code Online (Sandbox Code Playgroud) 使用相应的代码沙箱代码 https://codesandbox.io/s/competent-jepsen-r7n3d?file=/src/Guage.js,我能够调出圆环图。
我需要一些帮助,将其制作为半圆形甜甜圈,并将文本放置在中心以及颜色内部,如下所示。
更新:: 添加了周长: 90 * Math.PI ,旋转: 69.9 * Math.PI 使其成为半圆。仍在尝试将文本放置在图表上并将文本放置在中心
提前致谢。
表单组
this.locationForm = this.formBuilder.group({
locationName: new FormControl(null, Validators.required),
locationURL: new FormControl(null, Validators.required),
workTiming: this.formBuilder.array([
this.formBuilder.group({
beginTime: new FormControl(null,Validators.required),
})
])
})
Run Code Online (Sandbox Code Playgroud)
HTML代码:
<div formArrayName="workTiming" >
<div *ngFor="let item of workTiming.controls;
let pointIndex=index" [formGroupName]="pointIndex">
<div class="container">
<mat-form-field class="responsive">
<input type="time" required formControlName="beginTime" matInput placeholder="Begin Time">
<mat-error *ngIf="workTiming.get('beginTime').hasError('required')"> Enter begin time </mat-error>
</mat-form-field>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我需要一些关于如何访问 mat-error 中“beginTime”的 formControl 名称的帮助,因为我使用的是 formArray,我不确定如何访问它。如果我在代码中给出这样的错误,我会收到如下错误
ERROR TypeError: Cannot read property 'hasError' of null
Run Code Online (Sandbox Code Playgroud) 我正在尝试将自定义验证器添加到我的 component.ts 中
自定义验证器文件:
import { FormGroup, ValidationErrors } from '@angular/forms';
export class ProfileCustomValidators {
static validateTime(fg: FormGroup): ValidationErrors {
const staffForm = fg.get('staffForm')
const fromTime = staffForm.get('fromTime').value;
const toTime = staffForm.get('toTime').value;
if(fromTime > toTime) {
return {
'endTime': {
message: 'End time should be greater than start time'
}
}
}
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
组件.ts
export class StaffFrom implements onInit {
staffForm: FormGroup;
constructor(private fb: FormBuilder){}
ngOnInit() {
this.staffForm = this.fb.group({
fromTime: new FormControl(null, Validators.required),
toTime: new FormControl(null, …Run Code Online (Sandbox Code Playgroud) angular angular-reactive-forms angular7 angular-custom-validators
我正在尝试在下载 PDF 时在所有屏幕中添加页眉和页脚。我使用 jspdf-autotable 添加了带有模拟数据的表,并且能够下载它。但标题仅出现在下载的 PDF 的最后一页中
我需要一些帮助来获取所有屏幕中带有页码的页眉和页脚。请帮忙。
沙箱中的代码:https://codesandbox.io/s/upbeat-cannon-cfiry? file=/src/App.js:0-1257
代码在这里:
import jsPDF from "jspdf";
import "jspdf-autotable";
import { datas } from "./data";
import { renderToString } from "react-dom/server";
import PdfDocument from "./PdfDocument";
export default function App() {
const columns = [
{ title: "Rank", dataKey: "Rank" },
{ title: "Name", dataKey: "Name" },
{ title: "count", dataKey: "count" }
];
var rows = datas?.map((data) => ({
Rank: data?.Rank,
Name: data?.Name,
count: data?.count
}));
const downloadPdf = () => …Run Code Online (Sandbox Code Playgroud) angular ×5
angular7 ×2
cypress ×2
javascript ×2
reactjs ×2
background ×1
charts ×1
formarray ×1
jspdf ×1
modal-dialog ×1
react-native ×1
testing ×1