【发布时间】:2018-07-09 21:33:23
【问题描述】:
您好,我正在尝试在 AngularJS 应用程序中实现 Stripe 示例,我有一个初始化程序,它调用名为 initStripe(); 的函数,这与 Stripe 示例相同:
function initStripe()
{
$scope.stripe = Stripe('pk_test_6pRNasdwwehFeQd4XMUh');
$scope.elements = $scope.stripe.elements();
$scope.style = {
base: {
color: '#32325d',
lineHeight: '18px',
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
fontSmoothing: 'antialiased',
fontSize: '16px',
'::placeholder': {
color: '#aab7c4'
}
},
invalid: {
color: '#fa755a',
iconColor: '#fa755a'
}
};
$scope.card = $scope.elements.create('card', {style: $scope.style});
//console.log( document.getElementById('body') );
$scope.card.mount('#card-element');
}
问题出在最后一条指令$scope.card.mount('#card-element');,这里我得到这个错误:
您指定的选择器 (
#card-element) 适用于任何 DOM 当前在页面上的元素。
进行测试我可以检查移动位置的 HTML 代码是否有效,但在我需要的 div 中无效。
<body>
<!-- here works -->
<div ng-if="currentStep == 3">
<!-- here doesn't works -->
</div>
</body>
HTML 与 Stripe 网站示例相同:
【问题讨论】:
标签: javascript jquery html css angularjs