我正在尝试使此signaturePad正常工作。当我尝试实例化它时,我不确定。该模块适用于8号或8号以下的角度,我相信它可能与ES6兼容性有关。有人知道解决此问题的方法吗?
这是我的代码段(非常向前)app.ts ==> ...
import { BidiModule } from '@angular/cdk/bidi';
import { HttpClientModule } from '@angular/common/http';
import { SignaturePadModule } from 'angular2-signaturepad';
@NgModule({
declarations: [
AppComponent,
HomeComponent,
BpensiaComponent,
BmngComponent,
BindiComponent,
BpartComponent,
BuniqComponent,
BlogComponent,
AboutusComponent,
JoinformComponent,
],
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
HttpClientModule,
BidiModule,
AppRoutingModule,
SharedModule.forRoot(),
BrowserAnimationsModule,
SignaturePadModule,
joinForm.ts ==>
import { Component, OnInit, ViewChild } from "@angular/core";
import { SignaturePad } from 'angular2-signaturepad/signature-pad';
@Component({
selector: "app-joinform",
templateUrl: "./joinform.component.html",
styleUrls: ["./joinform.component.scss"]
})
export class JoinformComponent implements OnInit {
@ViewChild(SignaturePad, {static:false}) signaturePad: SignaturePad;
signaturePadOptions: Object = { // passed through to szimek/signature_pad constructor
'minWidth': 5,
'canvasWidth': 500,
'canvasHeight': 300
};
constructor() {}
ngOnInit(): void {}
ngAfterViewInit() {
// this.signaturePad is now available
this.signaturePad.set('minWidth', 5); // set szimek/signature_pad options at runtime
this.signaturePad.clear(); // invoke functions from szimek/signature_pad API
}
drawComplete() {
// will be notified of szimek/signature_pad's onEnd event
console.log(this.signaturePad.toDataURL());
}
drawStart() {
// will be notified of szimek/signature_pad's onBegin event
console.log('begin drawing');
}
提前发送
根据Github存储库问题,该库与Ivy(Angular 9的新渲染引擎)存在一些兼容性问题。
解决此问题的方法是替换组件中的以下行(joinForm.ts)。
import { SignaturePad } from 'angular2-signaturepad/signature-pad';
与
import { SignaturePad } from 'angular2-signaturepad;
这将解决问题,并且该this.signaturePad
对象将在ngAfterViewInit()
功能中可用
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句