npm

a-z-index

1.0.8 • Public • Published

Now only React!

How to use it:

data struct is array with object, the object must have a unique alpha key. If you set key with unalpha char, it's key will be set '#', indicate other.

For Dom: Please write the HTML struct must have realList className and data-key={cate.key} in cate render map div

<Azindex data={data} height={'500px'}>
      <div className='realList'>
         <div key={index} data-key={cate.key}>
         </div>
      </div>
</Azindex>
import { Azindex } from 'a-z-index'
function App() {
  var data = [
    {
      key: 'A',
      list: [
        1,2,3,4,5,6,7
      ]
    },
    {
      key: 'B',
      list: [
        1,2,3,4,5,6,7
      ]
    },
    {
      key: 'x',
      list: [
        1,2,3,4,5,6,7
      ]
    },
    {
      key: 'e',
      list: [
        1,2,3,4,5,6,7
      ]
    },
    {
      key: '1',
      list: [
        1,2,3,4,5,6,7
      ]
    }
  ]
  return (
    <div>
     <Azindex data={data} height={'500px'}>
      <div className='realList'>
        {
          data.map((cate, index)=>{
              return (
                <div key={index} data-key={cate.key}>
                <h1>{cate.key}</h1>
                <h4>{cate.key}</h4>
                <ul>
                  {
                    cate.list.map((item, index2)=>{
                      return <li key={index2}>{item}</li>
                    })
                  }
                </ul>
              </div>
              )
            })
          }
      </div>
     </Azindex>
    </div>
  );
}

export default App;

real effect

pSooWEd.png

Readme

Keywords

Package Sidebar

Install

npm i a-z-index

Weekly Downloads

2

Version

1.0.8

License

MIT

Unpacked Size

176 kB

Total Files

18

Last publish

Collaborators

  • su35