1.0.0-alpha.0 • Published 11 months ago

use-css-throttle v1.0.0-alpha.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

use-css-throttle

A composition api for css throttle, supports vue2.0 and vue3.0

NPM version Codacy Badge Test coverage npm download gzip License

Sonar

Installing

# use pnpm
$ pnpm install use-css-throttle

# use npm
$ npm install use-css-throttle --save

# use yarn
$ yarn add use-css-throttle

Usage

Use in Vue >=3.0

<script setup>
import { getCurrentInstance, onMounted } from 'vue'
import useCssThrottle from 'use-css-throttle'

const speaker = useCssThrottle({ lang: 'zh_CN' })

onMounted(() => {
  speaker.speak('new bee')
})

useExpose({ speaker })
</script>

Use in Vue 2.7

<script>
import useCssThrottle from 'use-css-throttle'

export default {
  setup() {
    const speaker = useCssThrottle({ lang: 'zh_CN' })
    speaker.speak('new bee')

    return { speaker }
  }
}
</script>

Use in Vue <=2.6

Add @vue/composition-api to the project.json dependencies and run install.

{
  "dependencies": {
    "@vue/composition-api": "latest"
  }
}
// main.js
import Vue from 'vue'
import VueCompositionApi from '@vue/composition-api'

Vue.use(VueCompositionApi)

new Vue({}).$mount('#app')
<script>
import useCssThrottle from 'use-css-throttle'

export default {
  setup() {
    const speaker = useCssThrottle({ lang: 'zh_CN' })
    speaker.speak('new bee')

    return { speaker }
  }
}
</script>

Using unpkg CDN

<!-- Add script tags to your html code, using CDN links to bring in -->
<script src="https://unpkg.com/use-css-throttle@1.1.0/dist/index.global.prod.js"></script>

Support & Issues

Please open an issue here.

License

MIT