我正在尝试在我的 ionic 3 项目中实现 angular2 签名板,但我遇到了上述问题的错误。我正在关注本教程链接。它在 ionic2 中运行良好,但是当我在 ionic 3 中尝试时,我收到如下错误
Failed to navigate: Template parse errors:
Can't bind to 'options' since it isn't a known property of 'signature-pad'.
1. If 'signature-pad' is an Angular component and it has 'options' input, then verify that it is part of this module.
2. If 'signature-pad' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<ion-col></ion-col>
<ion-col>
<signature-pad [ERROR ->][options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplete()"></signatur"): ng:///ConformsignModule/Conformsign.html@20:21
'signature-pad' is not a known element:
1. If 'signature-pad' is an Angular component, then verify that it is part of this module.
2. If 'signature-pad' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<ion-col></ion-col>
<ion-col>
[ERROR ->]<signature-pad [options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplet"): ng:///ConformsignModule/Conformsign.html@20:6
您可以在此获取完整代码,就像我在此 https://devdactic.com/signature-drawpad-ionic-2/中尝试所有内容一样
我认为当我使用深度链接导航时出现此错误,但是当我将组件导入 app.module.ts 时,一切正常
更新
这是我的 .ts 文件
export class Conformsign {
signature = '';
isDrawing = false;
finalData
@ViewChild(SignaturePad) signaturePad: SignaturePad;
@Input()
private signaturePadOptions: Object = { // Check out https://github.com/szimek/signature_pad
'minWidth': 2,
'canvasWidth': 400,
'canvasHeight': 200,
'backgroundColor': '#f6fbff',
'penColor': '#666a73'
};
constructor(public navCtrl: NavController, public navParams: NavParams, public toastCtrl: ToastController, public holders: Holders, public rest:Rest) {
this.finalData = this.holders.getData();
}
ionViewDidLoad() {
console.log('ionViewDidLoad Conformsign');
}
ionViewDidEnter() {
this.signaturePad.clear()
}
drawComplete() {
this.isDrawing = false;
}
drawStart() {
this.isDrawing = true;
}
savePad() {
this.signature = this.signaturePad.toDataURL();
this.signaturePad.clear();
let toast = this.toastCtrl.create({
message: 'New Signature saved.',
duration: 3000
});
toast.present();
let conformDelivery = {
order_id: this.finalData.order_id,
amountpaid:this.finalData.total,
customername:this.finalData.firstname,
signature:this.signature,
user_id:this.finalData.user_id,
customer_id:this.finalData.customer_id
}
}
clearPad() {
this.signaturePad.clear();
}
}
这是我的 .html
<ion-content>
<div class="title">Please draw your Signature</div>
<ion-row [ngClass]="{'drawing-active': isDrawing}">
<ion-col></ion-col>
<ion-col>
<signature-pad [options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplete()"></signature-pad>
</ion-col>
<ion-col></ion-col>
</ion-row>
<button ion-button full color="danger" (click)="clearPad()">Clear</button>
<button ion-button full color="secondary" (click)="savePad()">Save</button>
<ion-row>
<ion-col></ion-col>
<ion-col width-80>
<img [src]="signature"/>
</ion-col>
<ion-col></ion-col>
</ion-row>
</ion-content>