请问,vue报错 Getter is missing for computed property "methods".什么意思?
组件star
<template id="star">
<div class='star-box'>
<!--<p>满意度:{{starnum|percent(stars)}}</p>-->
<div v-for='n in stars' class='star starcount' @click='mousedown(n)'></div>
<div class='star-div'>
<div v-for="n in format" :style='n==format?stylelist:repstyle' class='star starbg' @click='mousedown(n)' ></div>
</div>
</div>
</template>
<script>
export default{
name:'star',
data:function(){
return {
isdown:false,
downnum:0,
}
},
props:['stars','starnum'],
computed:{
format:function(){
return Math.ceil(this.starnum)
},
stylelist:function(){
return {
width:50*(1-this.format + this.starnum)+'px',
}
},
repstyle:function(){
return {
width:50+'px',
}
},
// filters:{
// width:function(v){
// return v + 'px'
// },
// percent:function(v,n){
// var per = v / n
// if(per>=1){
// return '非常满意'
// }else if(per>=0.75){
// return '还不错'
// }else if(per>=0.5){
// return '一般'
// }else if(per>=0.25){
// return '有点差'
// }else{
// return '非常差'
// }
// }
// },
methods:{
mousedown(n){
if((n-0.5)>this.starnum){
n=n-0.5
}else if((n-0.5)==this.starnum){
n=n
}else{
n = n - 1
}
// this.$emit('input',n)
}
}
}
}
</script>
<style scoped="scoped">
.star-div{
/*float: left;*/
position: absolute;
}
.star{
width: 50px;
height: 50px;
background-size: 50px 50px;
background-repeat: no-repeat;
float: left;
}
.starcount{
background-image: url(images/star24_on@2x.png);
}
.starbg{
background-image: url(images/star24_off@2x.png);
}
</style>
父组件引用html:
<template>
<div>
我要打分:<input v-model.number="starnumber">
星星总数:<input v-model.number="stars">
<star :starnum='starnum' :stars='stars' @input='changenum'></star>
</div>
</template>
<script>
import star from 'components/star/star'
export default {
name: 'app',
components: {
star:star,
},
data(){
return{
/*星级组件*/
starnumber:5,
stars:5,
}
},
computed:{
starnum:function(){
if(this.starnumber>this.stars){
return this.stars
}else{
return this.starnumber
}
}
},
methods:{
//点击的星星,改变数字传递给星星组件
changenum:function(n){
this.starnumber = n
},
</script>
methods跟computed应该是同级的,你好像把methods放到了computed里面了。