【发布时间】:2018-09-03 08:52:03
【问题描述】:
我有一张付款表格,里面只有卡号、cvc、有效期和邮编。 我想添加帐单名称、帐单地址等字段。因此客户可以添加更多信息。
我该如何解决这个问题?
ngAfterViewInit() {
this.card = this.pmt.elements.create('card');
this.card.mount(this.cardElement.nativeElement);
}
我尝试过这样的事情......不是这样,因为它不起作用。
ngAfterViewInit() {
this.card = this.pmt.elements.create('card', {
billing_name: true
});
this.card.mount(this.cardElement.nativeElement);
}
【问题讨论】:
-
您在 ngAfterViewInit 的第 2 行引用的 this.cardElement 是什么?你能发布整个组件文件(ts和html)吗?
-
它是html中的一个元素..
<div id="card-element" #cardElement></div> -
您是否使用@ViewChild() 来获取对#cardElement 的引用?
-
是的,我做到了。``` @ViewChild('cardElement') cardElement: ElementRef;```