鍍金池/ 問答/C#  HTML/ vuex 棧溢出

vuex 棧溢出

<template>
    <div class= 'menubody'>
        <ul class= 'menulist'>
            <li class= 'menuitem' v-for= '(item, index) of list'>
                <router-link :to="{ path: item.route, query: { id: item.id} }"  :style="{paddingLeft: padding+'rem'}"  :class="[(nowindex===index)? 'active': '']">
                    {{item.name}}
                    <img src= '../assets/spread.png' v-if= 'item.isparent' @click= 'showitem(index, item.id)'/>
                    <span  class= 'addsymbol' v-if= 'item.name=="添加菜單"'></span>
                </router-link>
            <div class= 'children' v-show= 'nowindex===index'>
                 <tree-menu  :list= 'children' :padding= 'newpadding'></tree-menu>
            </div>
            </li>
        </ul>
    </div>
</template>
<script>
    import axios from 'axios';
    export default {
        name: 'TreeMenu',
        props: {
            list: {
                type: Array,
          default: function () {
            return []
          }
            },
            padding: {
                type:Number,
                default: 0.42
            }
        },
        computed: {
            newpadding() {
                return this.padding+0.1;
            },
            children() {
                console.log(1)
                return this.$store.state.tree
            }
        },
        data() {
      return {
          nowindex: null,
      }
       },
    methods: {
      showitem(index, id) {
          this.nowindex= this.nowindex===index? '': index;
        axios.get(`/api/${id}.json`).then(res=> {
            this.$store.commit('setTree', res.data.children)
        })
      },
      
      getInfo(index) {
            
        },
    },
    

    
        
    }
</script>

clipboard.png
為什么會出現(xiàn)棧溢出求解釋謝謝?。?!

回答
編輯回答
做不到

看你在哪個地方出現(xiàn)了死循環(huán)或者無限遞歸

2017年9月24日 23:37