我不确定我正在尝试做的事情是否有任何逻辑,但请尝试一下。
我正在尝试在我的 Angular 应用程序中添加 Veriff SDK。我得到以下错误。任何帮助表示赞赏。
.html
<button class="btn" [disabled]="isVerified"
(click)="myFn()">Finish</button>
.ts 文件
export class myComponent(){
isVerified : boolean = true;
ngOnInit() {
const veriff = Veriff({
host: 'https://stationapi.veriff.com',
apiKey: '',
parentId: 'veriff-root',
onSession: function(err, response) {
console.log(response.status) //success
window.veriffSDK.createVeriffFrame({ url: response.verification.url });
if( response && response.status === 'success'){
this.isVerified = !this.isVerified
}
.....} //rest of the code is here
在 ngOnInit () 上,我调用了 Veriff api。
我正在尝试如果响应成功则禁用 false。但是我得到了这个无法读取未定义的属性“isVerified”。如何解决这个问题。
您必须使用箭头函数(lambda 表达式)。否则如果你使用functions
它会改变this
.
这应该可以解决您的问题:
ngOnInit() {
const veriff = Veriff({
host: 'https://stationapi.veriff.com',
apiKey: '',
parentId: 'veriff-root',
onSession: (err, response) => {
console.log(response.status) //success
window.veriffSDK.createVeriffFrame({ url: response.verification.url });
if( response && response.status === 'success'){
this.isVerified = !this.isVerified
}
.....} //rest of the code is here
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句