鍍金池/ 問答/HTML/ vue星級評價(jià):報(bào)錯(cuò)Getter is missing for computed

vue星級評價(jià):報(bào)錯(cuò)Getter is missing for computed property "methods".

請問,vue報(bào)錯(cuò) 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 '還不錯(cuò)'
      //     }else if(per>=0.5){
      //       return '一般'
      //     }else if(per>=0.25){
      //       return '有點(diǎn)差'
      //     }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">
      星星總數(shù):<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:{
      //點(diǎn)擊的星星,改變數(shù)字傳遞給星星組件
      changenum:function(n){
        this.starnumber = n
    },
    
</script>
回答
編輯回答
落殤

methods跟computed應(yīng)該是同級的,你好像把methods放到了computed里面了。

2018年7月14日 14:18
編輯回答
你好胸

應(yīng)該是沒有把getter放到computed里面吧

2018年4月9日 21:14