簡單登入註冊例子實現redux功能

2021-10-02 23:47:35 字數 1810 閱讀 2936

以登入存貯賬號密碼為例:

actions部分:

actions/login.js:

export function updateaccount(value) 

}export function updatepsw(value)

}

reducers部分:

reducers/login.js

const statedata = 

const login = (state = statedata, action) => , state, )

case 'update_passwork':

return object.assign({}, state, )

default:

return state

}}export default login

redux/index.js: 

import  from 'redux'

import login from './reducers/login' //寫法就是單個redux寫法,每個功能寫乙個

const reducer = combinereducers()

export default reducer

入口檔案:

import react from 'react'

import reactdom from 'react-dom'

import '@/styles/index.scss'

import from 'redux'

import from 'react-redux'

import reducer from '@/redux'

import routers from '@/router/index'

const store = createstore(reducer)

reactdom.render(

, document.getelementbyid('root')

)

登入元件:

import react,  from 'react'

import './login.scss'

import from 'react-redux';

import from 'redux';

import * as loginactions from '@/redux/actions/login'

class login extends component

handleaccount(e)

handlepw(e)

handlesubmit()

render()

}//需要渲染什麼資料

function mapstatetoprops(state)

}//1、不使用bindactioncreators時候:

// function mapdispatchtoprops(dispatch) ),

// updatepw: (value) => dispatch(),

// }

// }

// 2、通過把aciont和dispatch鏈結起來

function mapdispatchtoprops(dispatch)

}export default connect(mapstatetoprops , mapdispatchtoprops)(login);

即可實現登入賬號密碼的狀態儲存 

flask登入註冊簡單的例子

auther hhh5460 time 2018 10 05 address dongguan yuehua from functools import wraps from flask import flask,request,render template,redirect,url for,fl...

C 擴充套件python ,簡單例子,實現加法

首先編寫lgadd model.cpp define py ssize t clean include python.h 由於 python 可能會定義一些能在某些系統上影響標準標頭檔案的預處理器定義,因此在包含任何標準標頭檔案之前,你 必須 先包含 python.h。c 實現加法,傳入倆個int型...

SElinux 學習筆記 例子實現

測試環境介紹 作業系統 fedora 22 mate fedora 21 環境搭建 root yum install y policycoreutils python policycoreutils devel selinux policy devel setools hddtemp git vim...