Below I will share with you an example of using vue to implement a Taobao star rating. It has a good reference value and I hope it will be helpful to everyone.
The example is as follows:
<template> <p id="shoplist"> <p class="all" > <input type="radio" name="b" value="0" v-model="inputdata"/> <span>★</span> <input type="radio" name="b" value="1" v-model="inputdata" /> <span>★</span> <input type="radio" name="b" value="2" v-model="inputdata" /> <span>★</span> <input type="radio" name="b" value="3" v-model="inputdata" /> <span>★</span> <input type="radio" name="b" value="4" v-model="inputdata" /> <span>★</span> <input type="radio" name="b" value="5" v-model="inputdata" /> <span>★</span> </p> </p> </template> <script> export default { name:'shoplist', data(){ return { inputdata:'5' } }, methods:{ }, watch: { inputdata(value) { console.log(value) } } } </script> <style> .all>input{opacity:0;position:absolute;width:2em;height:2em;margin:0;} .all>input:nth-of-type(1), .all>span:nth-of-type(1){display:none;} .all>span{font-size:2em;color:gold; -webkit-transition:color .2s; transition:color .2s; } .all>input:checked~span{color:#666;} .all>input:checked+span{color:gold;} </style>
The above is what I compiled for everyone, I hope it will be helpful to everyone in the future.
Related articles:
The vue page switches to the scroll page to display the top example_vue.js
Let’s talk about JS Usage of animation library Velocity.js
vue filter filter instance detailed explanation
The above is the detailed content of How to achieve Taobao-like star rating in vue. For more information, please follow other related articles on the PHP Chinese website!