【发布时间】:2019-07-29 13:52:45
【问题描述】:
我尝试使用不基于 vue 的外部脚本 (https://libs.crefopay.de/3.0/secure-fields.js)
我通过 -tags 将脚本添加到 index.html 中
但是当我尝试对一个对象进行 intsanciate 时,就像在脚本发布者的示例中一样。
let secureFieldsClientInstance =
new SecureFieldsClient('xxxxx',
this.custNo,
this.paymentRegisteredCallback,
this.initializationCompleteCallback,
configuration)
Vue 说“'SecureFieldsClient' 没有定义”
如果我使用 这个。
let secureFieldsClientInstance =
new this.SecureFieldsClient('xxxxx',
this.custNo,
this.paymentRegisteredCallback,
this.initializationCompleteCallback,
configuration)
secureFieldsClientInstance.registerPayment()
Vue 说:v-on 处理程序中的错误:“TypeError:this.SecureFieldsClient 不是构造函数”
我的代码:
methods: {
startPayment () {
this.state = null
if (!this.selected) {
this.state = false
this.msg = 'Bitte Zahlungsweise auswählen.'
} else {
localStorage.payment = this.selected
let configuration = {
url: 'https://sandbox.crefopay.de/secureFields/',
placeholders: {
}
}
let secureFieldsClientInstance =
new SecureFieldsClient('xxxxx',
this.custNo,
this.paymentRegisteredCallback,
this.initializationCompleteCallback,
configuration)
secureFieldsClientInstance.registerPayment()
// this.$router.replace({ name: 'payment' })
}
}
}
我的错误在哪里?
编辑: 更新了坑题
【问题讨论】:
-
您是否尝试将其添加到 index.html 文件中?
-
怎么样?起始文件是 App.vue。 index.html 已生成。
-
啊找到了 index.html 但仍然得到“TypeError: this.SecureFieldsClient is not a constructor”
标签: javascript vue.js