1、安装
cnpm install shortid --save
2、使用
const id=shortid.generate()
代码示例:
import {ADD_FLASH_MESSAGE} from '../constants'
import shortid from 'shortid'
const flashMessage=(state=[],action)=>{
switch(action.type)
{
case ADD_FLASH_MESSAGE:
return [...state,{
id:shortid.generate(),
type:action.message.type,
text:action.message.text
}]
}
}
export default flashMessage;