gpt4 book ai didi

canvas - ionic 2 框架签名板表单生成器问题

转载 作者:行者123 更新时间:2023-12-02 06:44:11 24 4
gpt4 key购买 nike

当我尝试导航到基于 Ionic 2 框架的应用程序中的 mytest 页面时,出现此错误:

Runtime Error Uncaught (in promise): TypeError: sp is not a constructor TypeError: sp is not a constructor at SignaturePad.ngAfterContentInit (http://localhost:8100/build/main.js:63958:29) at callProviderLifecycles (http://localhost:8100/build/main.js:11544:18) at callElementProvidersLifecycles (http://localhost:8100/build/main.js:11525:13) at callLifecycleHooksChildrenFirst (http://localhost:8100/build/main.js:11509:17) at checkAndUpdateView (http://localhost:8100/build/main.js:12526:5) at callViewAction (http://localhost:8100/build/main.js:12838:17) at execComponentViewsAction (http://localhost:8100/build/main.js:12784:13) at checkAndUpdateView (http://localhost:8100/build/main.js:12529:5) at callViewAction (http://localhost:8100/build/main.js:12838:17) at execEmbeddedViewsAction (http://localhost:8100/build/main.js:12810:17) at checkAndUpdateView (http://localhost:8100/build/main.js:12524:5) at callViewAction (http://localhost:8100/build/main.js:12838:17) at execComponentViewsAction (http://localhost:8100/build/main.js:12784:13) at checkAndUpdateView (http://localhost:8100/build/main.js:12529:5) at callWithDebugContext (http://localhost:8100/build/main.js:13511:42)

我在 angular2-signaturepad 节点模块的 SignaturePad.prototype.ngAfterContentInit 函数中放置了一些调试代码,看起来 Canvas 对象是空的。

我做错了什么?

我的源代码:

app.module.ts:

...

import { SignaturePadModule } from 'angular2-signaturepad';
import { IonicStorageModule } from '@ionic/storage';

...

imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
CloudModule.forRoot(cloudSettings),
SignaturePadModule,
IonicStorageModule.forRoot()
],

...

mytest.ts

...

import { SignaturePad } from 'angular2-signaturepad/signature-pad';
import { Storage } from '@ionic/storage';

...

@ViewChild('mySlider') mySlider: any;
@ViewChild(SignaturePad) signaturePad: SignaturePad;

signaturePadOptions: Object = {
'minWidth': 2,
'canvasWidth': 400,
'canvasHeight': 200,
'backgroundColor': '#f6fbff',
'penColor': '#666a73'
};

constructor(public viewCtrl: ViewController,
public auth: Auth,
public navCtrl: NavController,
public navParams: NavParams,
public events: Events,
public tabsService: TabsService,
public formBuilder: FormBuilder,
public alert: AlertController,
public storage: Storage) {
this.slide2Form = formBuilder.group({ });
}
...

mytest.html

<ion-content>
<ion-slides #mySlider>
<ion-slide>
<ion-list no-lines>
<form [formGroup]="slide2Form">
<ion-item>
<ion-label>Date</ion-label>
<ion-datetime displayFormat="MMMM/DD/YYYY" formControlName="signatureSigned"></ion-datetime>
</ion-item>

<ion-item>
<signature-pad [options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplete()"></signature-pad>
<button ion-button full color="danger" (click)="clearPad()">Clear</button>
</ion-item>
</form>
</ion-list>
</div>
</ion-slide>
</ion-slides>
</ion-content>
...

最佳答案

您的代码似乎没问题,但可能是signature_pad的问题,也许您没有以正确的方式导入它,请尝试:

import * as SignaturePad from 'signature_pad';

从这里查看代码: https://github.com/wulfsolter/angular2-signaturepad/blob/master/signature-pad.ts

似乎“sp”正在尝试使用“require”加载模块

This link也可能对这个问题有所启发

关于canvas - ionic 2 框架签名板表单生成器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44340147/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com