Skip to content

viivue/easy-hash

Repository files navigation

Easy Hash

release Netlify Status

Demo: https://easy-hash.netlify.app

Getting started

CDN

<script src="https://cdn.jsdelivr.net/gh/viivue/[email protected]/dist/easy-hash.min.js"></script>

Initialize

We can use this library promptly after import it into your project

Methods

Usage Description
EasyHash.add(hash) Add new hash to the URL and replace the current one if any (containing "#" or not are both acceptable)
EasyHash.remove() Remove current hash value
EasyHash.getHash() Get current hash
EasyHash.on(eventName, callback) Assign events

Events

Name Description
"change" After value changed
EasyHash.on('change', () => {
    // do something
})
// the same as window.addEventListener('hashchange',()=>{})

Deployment

# Run dev server
npm run dev

# Build dev site
npm run build

# Generate production files
npm run prod

License

MIT License

Copyright (c) 2023 ViiVue