我有以下代码:
angular.module("myApp", []).controller("myController", function($scope) {
$scope.value = '';
$scope.keyList = [{
id: 1,
name: '1'
}, {
id: 2,
name: '2'
}, {
id: 3,
name: '3'
}];
$scope.modifyValue = function(item) {
$scope.value = $scope.value + item.name;
}
});
.wrapper {
display: flex;
flex-direction: column;
justify-content: space-between;
width: 100px;
height: 100px;
}
.keys {
display: flex;
justify-content: space-between;
}
.key {
width: 20px;
height: 20px;
background-color: grey;
color: white;
text-align: center;
}
.key:hover {
background-color: darkgrey;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div class="wrapper" ng-app="myApp" ng-controller="myController">
<div class="keys">
<div class="key" ng-repeat="item in keyList" ng-click="modifyValue(item)">{{item.name}}</div>
</div>
<input ng-model="value">
<button ng-click="value = ''">Clear</button>
</div>
这适用于桌面(IE,Firefox和Chrome),三星标签(镀铬)和ipad(徒步旅行)。我对这个解决方案唯一的问题是ipad上的性能(在safari中)。当我在桌面或三星选项卡上快速单击时,它会快速汇总我的值,并且点击也很快。但是当我在我的ipad上的三个数字中快速触摸它时,它会动摇并跳过一些数字。示例:当我快速点击1-2-3时,它会摇晃并跳过2,因此在输入中只有13,如果是123.我不知道如何解决它...我希望有人可以帮助我。感谢。