<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>打分</title>
</head>
<style>
.clickStar{
font-weight: 800;
font-size: 30px;
color: #ddd;
}
.red{
color: red;
}
</style>
<body>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios@0.12.0/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/lodash@4.13.1/lodash.min.js"></script>
<div id="app">
<span class="clickStar" v-on:click='starclick(1)' v-bind:class='{red:red1}' >★</span>
<span class="clickStar" v-on:click='starclick(2)' v-bind:class='{red:red2}' >★</span>
<span class="clickStar" v-on:click='starclick(3)' v-bind:class='{red:red3}'>★</span>
<span class="clickStar" v-on:click='starclick(4)' v-bind:class='{red:red4}'>★</span>
<span class="clickStar" v-on:click='starclick(5)' v-bind:class='{red:red5}'>★</span>
<span>{{evaluation}}</span>
</div>
<script>
var vm = new Vue({
el: '#app',
data: {
score:10.63,
red1:false,
red2:false,
red3:false,
red4:false,
red5:false,
evaluation :null,
},
methods: {
starclick(param){
if(param==1){
this.red1=true;
this.red2=false;
this.red3=false;
this.red4=false;
this.red5=false;
this.evaluation="非常差";
};
if(param==2){
this.red1=true;
this.red2=true;
this.red3=false;
this.red4=false;
this.red5=false;
this.evaluation="差";
};
if(param==3){
this.red1=true;
this.red2=true;
this.red3=true;
this.red4=false;
this.red5=false;
this.evaluation="一般";
};
if(param==4){
this.red1=true;
this.red2=true
this.red3=true;
this.red4=true;
this.red5=false;
this.evaluation="好";
};
if(param==5){
this.red1=true;
this.red2=true
this.red3=true
this.red4=true
this.red5=true;
this.evaluation="非常好";
};
},
change(str) {
alert("点击之后");
}
},
});
</script>
</body>
</html>