Vue没有得到数组值

时间:2017-09-25 14:02:49

标签: arrays checkbox vue.js

如果我选中一个复选框,则vue不会给数组赋值,即使这些项在检查DOM树时有值。

<div class="column">
    <div class="card">
        <div class="card-content">
            <label for="players" class="label">{{ trans_choice('sites.players', 2) }}</label>
            <input type="hidden" name="players" :value="playerSelected">

            <b-checkbox-group v-model="playerSelected">
                @foreach ( $players as $player )
                <div class="field">
                    <b-checkbox :custom-value="{{ $player->id }}">{{ $player->nickname }}</b-checkbox>
                </div>
                @endforeach
            </b-checkbox-group>
        </div>
    </div>
</div><!--column-->

<script>
    var app = new Vue({
        el: '#app',
        data: {
            playerSelected: {!! $team->players->pluck('id') !!},
            gameSelected: {!! $team->games->pluck('id') !!}
        }
    });
</script>

0 个答案:

没有答案