:href="[category.module+'/'+category.id]"


<template>
    <ul>
        <!--分类列表-->
        <li v-for="category in results" :key="category-list">
            <a :href="[category.module+'/'+category.id]">{{ category.title }} </a>
            <ul v-if="category.children != ''">
                <li v-for="child in category.children" :key="child-list">
                    <a :href="[child.module+'/'+child.id]">{{ child.title }} </a>
                </li>
            </ul>
        </li>
    </ul>
</template>

<script>
    export default {
        data () {
            return {
                results: []
            }
        },
        mounted() {
             var that = this
             axios.get('/api/categories')
            .then(function (response) {
                that.results = response.data.data
                console.log(that.results)
            });
        }
    }
</script>

Logo

前往低代码交流专区

更多推荐