From 4d1d8a1789655d85ccf57a0cc1cda961c4efdc73 Mon Sep 17 00:00:00 2001 From: CPunisher <1343316114@qq.com> Date: Mon, 4 May 2020 23:16:45 +0800 Subject: [PATCH] Fix param setting bugs --- src/components/QrRendererBase.js | 14 +++++++++----- src/components/Qrcode.js | 6 +++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/QrRendererBase.js b/src/components/QrRendererBase.js index 76933ba..e965ff4 100644 --- a/src/components/QrRendererBase.js +++ b/src/components/QrRendererBase.js @@ -7,16 +7,20 @@ function listPoint(props) { const qrcode = props.qrcode; const nCount = qrcode.getModuleCount(); const pointList = new Array(nCount); - const params = props.params; + let type = props.params[1]; + let size = props.params[0]; let id = 0; + + if (size <= 0) size = 1.0 + for (let row = 0; row < nCount; row++) { for (let col = 0; col < nCount; col++) { if (qrcode.isDark(row, col)) { - if (params[1] == 0) - pointList.push() - else if (params[1] == 1) - pointList.push() + if (type == 0) + pointList.push() + else if (type == 1) + pointList.push() } } } diff --git a/src/components/Qrcode.js b/src/components/Qrcode.js index cb97858..7f9ea8d 100644 --- a/src/components/Qrcode.js +++ b/src/components/Qrcode.js @@ -143,8 +143,9 @@ class Qrcode extends React.Component { type="number" className="Qr-input small-input" placeholder="10" - value={this.state.paramValue[this.state.selectedIndex][index]} - onChange={(e) => this.setParamValue(index, e.target.value)}/> + defaultValue={this.state.paramValue[this.state.selectedIndex][index]} + onBlur={(e) => this.setParamValue(index, e.target.value)} + onKeyPress={(e) => {if(e.key === 'Enter') {this.setParamValue(index, e.target.value); e.target.blur()}}}/> ); } } @@ -164,7 +165,6 @@ class Qrcode extends React.Component { } render() { - console.log(1) return (