Skip to content

Commit

Permalink
fix(设置车牌): 修复iphone5s下无法设置车牌
Browse files Browse the repository at this point in the history
  • Loading branch information
liaoyinglong committed Apr 9, 2018
1 parent 80fb292 commit 8b5440a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
42 changes: 42 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,48 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script>
"use strict";


(function (doc, win) {
var docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function recalc() {
var clientWidth = docEl.clientWidth;

if (clientWidth > 450) {
clientWidth = 450;
}

if (!clientWidth) return;
var u = navigator.userAgent; //android

var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //ios

var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios缁堢

var isiOS10 = !!u.match(/\(i[^;]+;( U;)? CPU iPhone OS 10_.+Mac OS X/);

if (isAndroid) {
docEl.style.fontSize = 16 * (clientWidth / 320) + 'px';
} else if (isiOS) {
docEl.style.fontSize = 16 * (clientWidth / 320) + 'px';

if (isiOS10) {
docEl.style.fontSize = 15 * (clientWidth / 320) + 'px';
}
} else {
docEl.style.fontSize = 16 * (clientWidth / 320) + 'px';
}
};

if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);

</script>
<title>Document</title>
</head>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "plate-number-input",
"version": "1.0.1",
"scripts": {
"start": "webpack-dev-server --mode development --open --port 9090",
"start": "webpack-dev-server --mode development --open --host 0.0.0.0 --port 9090",
"dev": "webpack-dev-server --mode development --open --port 9090",
"build": "webpack --mode production",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ export default class plateNumberInput {
// TODO: 设置默认车牌号
plateNumber = plateNumber.trim()
const onceSetInputFocus = once(index => this.setInputFocus(index))
;[...this.inputSpans].forEach((span, index) => {
for (let index = 0; index < this.inputSpans.length; index++) {
const span = this.inputSpans[index]
span.innerText = plateNumber[index] || ''
alert(plateNumber[index])
if (plateNumber[index] === undefined) return onceSetInputFocus(index)
if (index === this.inputSpans.length - 1) return onceSetInputFocus(index)
})
}
}
/**
* 设置车牌类型
Expand Down

0 comments on commit 8b5440a

Please sign in to comment.