[Vuejs]-How to add star when clicked on vue.js 2?

0👍

One approach would be to add a star variable to your data with a default value of 3 and then follow this example in the vue.js docs on form input bindings.

It will be something like this:

<input v-for="item in items" type="radio" v-model="star" v-bind:value="item.value">
<span>Picked: {{ star }}</span> //for testing that the var changes.

Finally, you would want to send the star to your backend:

methods:{
        rate: function () {
        var star = this.star
            this.$http.post(window.BaseUrl + '/star', {star: star}).then(function (response) {
                console.log('submitted');
            });
        },

Leave a comment