左侧边栏没有显示item.name

来源:17-2 左侧menu布局

慕雪0323865

2018-02-25

<template>
  <div class="goods">
    <div class="menu-wrapper">
      <ul>
        <li v-for="item in goods">
          <span class="text">
              <span v-show="item.type>0" class="icon" :class="classMap[item.type]"></span>{{item.name}}
          </span>
        </li>
      </ul>
    </div>
    <div class="foods-wrapper"></div>
  </div>
</template>

<script type="text/ecmascript-6">
 import axios from 'axios';

 const ERR_OK = 0;
 export default {
    props: {
      seller: {
        type: Object
      }
    },
 data() {
      return {
        goods: []
      };
 },
 created() {
     this.classMap = ['decrease', 'discount', 'guarantee', 'invoice', 'special'];
 var that = this;
 axios.get('api/goods').then(function(response) {
       response = response.data;
 if (response.errno === ERR_OK) {
         that.goods = response;
 console.log(that.goods);
 }
     }).catch(function (error) {
       console.log(error);
 });
 }
  };
</script>

<style lang="stylus" rel="stylesheet/stylus">
 .goods
 display flex
 position absolute
 top 174px
 bottom 46px
 width: 100%
    overflow hidden
 .menu-wrapper
 flex 0 0 80px
 width 80px
 background #f3f5f7
 .goods-wrapper
 flex 1
</style>


写回答

1回答

ustbhuangyi

2018-02-26

有去对比我这里的源码吗:https://github.com/ustbhuangyi/vue-sell

0
3
慕雪0323865
老师我在问一下 我贴的这段代码 response = response.data 这段已经赋值给response了 为什么 下面that.goods = response; 这样就没用 that.goods = response.data 才能显示出来
2018-02-26
共3条回复

Vue.js2.5+cube-ui重构饿了么App(经典再升级)

掌握Vue1.0到2.0再到2.5最全版本应用与迭代,打造极致流畅的WebApp

9868 学习 · 4162 问题

查看课程