返回

vue.js-Vue组件道具值似乎不在模板上

发布时间:2022-08-12 17:37:34 267
# 前端

在我的 main.js 中一切都很好

import User from './components/User.vue'

new Vue({

    el: '#user',

    render: h => h(User),

    data() {

        return {

            groups: []

        }

    },

    mounted() {

        this.getGroups();

    },

    methods: {

        getGroups: function () {

            axios.get('http://vagrant.dev/groups')

                .then(response => this.groups = response.data)

                .catch(error => console.log(error));

        }

    }

});

User.vue

<template>

    <div id="user">

        {{groups}} <!-- must be printed but it doesn't seem -->

    </div>

</template>

<script>

    export default {

        name: 'user',

        props: ['groups']

    }

</script>

和 index.html

<div id="user">

    <user :groups="groups"></user>

</div>

错误在哪里?

我没有收到任何错误,但我不明白为什么该值没有打印在屏幕上

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(2)
按点赞数排序
用户头像
下一篇
C# 异步等待 - 我需要等待吗? 2022-08-12 15:48:38