0

私は にとても慣れていませんvue.js

webpack で単一ファイル コンポーネントを使用してい{{operating.totaloperating}}ますoperating。どうやってやるの?小道具として渡そうとすると、未定義と表示されます。

このコンポーネントにはテンプレートからのみ小道具を渡すことができますが、ファイル自体では渡すことができません。

<template>
    <tr v-for="operating in operatings" :operating="operating">
        <th scope="row">{{$index+1}}</th>
        <td>{{operating.name}}</td>
        <td>-</td>
        <td>{{operating.totaloperating}}</td>
    </tr>
</template>

<script>
    export default {
        props: ['operating'],
        data: function () {
            return {
                preloader: true,
                operatings: []
            }
        },

        methods: {

            fetchTotal: function () {
                this.$http.get('/api/totaloperating').then((response) => {
                    this.$set('operatings', response.json()),

                });
            }
        },



        ready: function () {

            this.fetchTotal()

        }
    }
</script>
4

1 に答える 1

1

:operating="operating"はコンポーネントではないため、 から削除する必要trがあります。また、小道具operatingは役に立たない。このコンポーネントを に必ず挿入してください。挿入し<tbody>ないと、まったく機能しません。コンソールのエラーについて。

于 2016-08-23T10:03:44.007 に答える