A Vue2 component of rating.
first:
npm install st-rating
You can choose to import st-rating
globally or locally.
import Vue from 'vue'
import Rating from './plugins/ratings/index'
Vue.use(Rating)
then in you .vue
file, you can write like this:
<st-rating :once="true"></st-rating>
<template>
<rating :once="true"></rating>
</template>
<script>
import rating from 'st-rating'
export default {
/*...*/
components: {
rating
}
/*...*/
}
</script>
name | type | isRequired | default | meaning |
---|---|---|---|---|
once | Boolean | no | false | If true, just click once |
stars | Number | no | 0 | Showed stars when mounted. |
If component has been clicked (starred), you can be informed by means of this:
<rating @starred="handleStarred"></rating>
<script>
methods: {
handleStarred () {
alert('Starred')
}
}
</script>