vue href链接拼接

: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>

猜你喜欢

转载自blog.csdn.net/tang05709/article/details/80886697