react 修改state某一屬性值


1.state

// 篩選框相關數據
            searchSelect: { term: { value: '學期', key: '', options: [] }, type_of_personnel: { value: '教師類型', key: '', options: [] }, business_type: { value: '業務類型', key: '', options: [] },cycle_year: { value: '年', key: '', options: [] },cycle_month: { value: '月', key: '', options: [] } },

2.修改state

            let cycle_month = Object.assign({}, this.state.searchSelect.cycle_month, { key: dateString.split('-')[0] })
            let cycle_year = Object.assign({}, this.state.searchSelect.cycle_year, { key: dateString.split('-')[1] })
            let searchSelect = Object.assign({}, this.state.searchSelect, { cycle_month:cycle_month , cycle_year :cycle_year })

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM