我需要动态更改签名板的宽度。我该怎么办?
<signature-pad class="signature w-50-p" id="sign_canvas" fxFlexAlign.xs="center"></signature-pad>
我需要动态更改签名板的宽度。我该怎么办?
<signature-pad class="signature w-50-p" id="sign_canvas" fxFlexAlign.xs="center"></signature-pad>
html:
<signature-pad fxFlex="1 1 50" (window:resize)="resizeSignaturePad()"
class="signature"
id="sign_canvas" fxFlexAlign.xs="center"></signature-pad>
ts:
resizeSignaturePad() {
this.signaturePad.set('canvasWidth',document.getElementById("sign_canvas").offsetWidth);
this.signaturePad.clear();
}
,
我今天在 Angular 11 上实现了这个。这个答案建立在 Markomar 的答案之上。希望这可以为某人省去一些头痛。简而言之,由于一些奇怪的下划线,我不得不使用 queryPad() 方法手动设置画布大小。我在我喜欢大小的元素上使用了模板变量 (#form),并使用 AfterViewInit 而不是 OnInit 使其正确初始化。
@ViewChild('form') formElement: ElementRef;
resizeSignature() {
this.signature.queryPad()._canvas.width = this.formElement?.nativeElement.offsetWidth;
}
ngAfterViewInit(): void { this.resizeSignature(); }
,
您可以尝试以下方法:
if (cellDescription.text == "") {
cellDescription.isHidden = true
cellTitle.centerYAnchor.constraint(equalTo: button.centerYAnchor,constant: 4).isActive = true
} else {
cellDescription.isHidden = false
cellTitle.centerYAnchor.constraint(equalTo: button.centerYAnchor,constant: 4).isActive = false
}