Dom:
<input id="bankCardInput" type="text" onfocus="console.log('inputBox is focused');" v-model="AcctNo" v-change="CardBinQry2()" v-blur="CardBinQry()" maxlength="19" style="width: 70%;">
JS:
$scope.CardBinQry2 = function () {
if (!$scope.AcctNo) {
return;
}
var params = {
"AcctNo": $scope.AcctNo
};
if ($scope.AcctNo.length < 16) {
$scope.BankExist = false;
$scope.BankName = '';
return;
}
$remote.post("BankAmericardQuery.do", params, function (data) {
if (data.resultMap.BankName.indexOf('银行') > -1) {
$scope.BankName = data.resultMap.BankName;
$scope.BankExist = true;
}
setTimeout(function () {
var input = document.getElementById('bankCardInput');
input.focus();
},1000)
},function (error) {
if (error.jsonError[0]._exceptionMessageCode == "not.supported.by.the.bank.card")
$scope.BankName = "卡不支持";
})
};
每次,CardBinQry2()方法都运行成功,我想查看“ inputBox已聚焦”日志,但是没有。有人告诉我为什么吗?
答案 0 :(得分:0)
您可以使其功能
setTimeout(function () {
callback()
},1000)
function callback() {
var input = document.getElementById('bankCardInput');
input.focus();
}