vue这样写这个合理吗?

if判断语句这样写合理吗 为什么感觉这样写很low呢

<input type="text" v-model="name"><button @click="add">提交</button>

data () {    return {
      name:'',
      user:[]
    }
},
methods: {
    add () {      if (this.user.length > 5){
        alert('长度过长')        return false
      }      this.user.push(this.name)      this.name = ''
    }
}


泛舟湖上清波郎朗
浏览 543回答 1
1回答

胡说叔叔

只要能正常工作,就不&nbsp;low,写代码又不是炫技。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Vue.js