angular - 添加 src 的 Angular 7 构建路径在哪里?
问题描述
我正在使用这个条纹角度来实现条纹信用卡处理。按照网站上的说明操作后,我无法访问 window.Stripe。
这是我的组件文件:
import { Component } from '@angular/core'
import { environment } from '../environments/environment'
import { CreditCardService } from '../_services/creditcard.service'
import { StripeScriptTag } from "stripe-angular"
@Component({
selector: 'app-stripe',
templateUrl: './stripe.component.html',
styleUrls: ['./stripe.component.css']
})
export class StripeComponent {
private publishableKey:string = `${environment.stripeKey}`;
constructor(private creditCardService: CreditCardService,
public StripeScriptTag:StripeScriptTag) {
console.log('publishable key ',`${environment.stripeKey}` )
console.log('window.Stripe ', window.Stripe )
}
错误是,“ ‘Window’类型上不存在属性‘Stripe’。 ”
这段代码放在组件和主索引html中
<script src="https://js.stripe.com/v3/"></script>
这暴露了条纹,但窗口没有找到它。
我读到我应该将该路径添加到 webpack 构建路径。我怎么做?
解决方案
当我将 window.Stripe 替换为 Stripe 时,错误消失并添加了 Stripe:any
推荐阅读
- linux - 即使 .config 存在,内核也会提示输入配置选项
- c# - 使用枚举器实例化列表
- wordpress - “where 子句”中的未知列“add_new_page”
- perl - 在使用“strict refs”时不能使用字符串(“”)作为 HASH ref
- c# - RegEx 需要将数字匹配到小数点后 2 位,可选 $ 和逗号
- meteor - 使用 simpl-schema 时字段 XXX 中的未知键
- angular - 是否可以删除或禁用或隐藏angular4中选择属性的下拉选项
- java - Java Media Framework 安装失败
- php - 使用通过rest apis快速结帐的Paypal一次性购买和定期付款
- c# - 发现数据源的模式