产生唯一的随机数

192 阅读1分钟
在redux源码的的until文件夹的actionTypes看到

Math.random()
  .toString(36)
  .substring(7) 
  .split('')
  .join('.')

源码部分:

const randomString = () =>
  Math.random()
    .toString(36)
    .substring(7)
    .split('')
    .join('.')
const ActionTypes = {
  INIT: `@@redux/INIT${randomString()}`,
  REPLACE: `@@redux/REPLACE${randomString()}`,
  PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
}
export default ActionTypes