From 1520ecfcf6660419bd3ff973f2f39d2496288bc1 Mon Sep 17 00:00:00 2001 From: CPunisher <1343316114@qq.com> Date: Thu, 14 May 2020 13:55:31 +0800 Subject: [PATCH] params' default value --- src/reducers/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/reducers/index.js b/src/reducers/index.js index 074841f..161df17 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -16,6 +16,7 @@ const initialState = { } export default function appReducer(state = initialState, action) { + console.log(state.paramValue) switch (action.type) { case actionTypes.GENERATE_QR_INFO: { let text = action.text; @@ -53,7 +54,13 @@ export default function appReducer(state = initialState, action) { } const newItem = item.slice(); - newItem[action.paramIndex] = isNaN(action.value) ? action.value : parseInt(action.value); + let newValue = action.value; + if (newValue.length <= 0) + newValue = state.paramInfo[action.rendererIndex][action.paramIndex].default; + console.log(newValue) + + if (!isNaN(newValue)) newValue = parseInt(newValue); + newItem[action.paramIndex] = newValue; return newItem; }) });