首页 新闻 会员 周边 捐助

vue报了个无限循环的错误。。You may have an infinite update loop in a component render function.

0
悬赏园豆:30 [已关闭问题] 关闭于 2018-07-17 16:43

输出的结果是没有任何问题的,但是浏览器就是会报这个错误

复制代码
<template>
    <div>
      <ul v-if="data.length>0">
        <li v-for="item in data" :key="item.id">
          <div class="foot_title" v-html="dateFormat(item.time)"></div>
          <div class="foot_list" v-for="list in item.commodityList" :key="list.id">
              <div class="foot_desc">
                  <div>{{list.productName}}</div>
              </div>
          </div>
        </li>
      </ul>
      <div v-else class="no-collect">
        <p>暂无浏览历史~</p>
      </div>
  </div>
</template>
js部分:data () { return { data: [ {time: '07/16', commodityList: [ {productName: '苹果'}, {productName: '苹果'} ] }, {time: '07/13', commodityList: [ {productName: '雪梨'}, {productName: '雪梨'} ] }, {time: '07/12', commodityList: [ {productName: '西瓜'}, {productName: '西瓜'} ] } ], titleText: '今天' } }, methods: { dateFormat (val = '') { let myDate = new Date() // 获取系统当前时间 let day1 = new Date(val) let day2 = new Date(myDate.getMonth() + 1 + '/' + myDate.getDate()) const number = (day2 - day1) / (1000 * 60 * 60 * 24) if (number === 0) { //问题出在这里!!! this.titleText = '今天' } else if (number === 1) { this.titleText = '昨天' } else { this.titleText = val console.log(number) } return this.titleText } }
复制代码
南方有梦,远方有止的主页 南方有梦,远方有止 | 初学一级 | 园豆:185
提问于:2018-07-17 11:16
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册