LoginSignup
2
0

More than 3 years have passed since last update.

can not set reatcive property on undefined,Vueで複数選択可のチェックボックスを実装するときのエラー

Last updated at Posted at 2019-07-28

Vueで次のエラーを解消するための一つの方法。
ノートのメモなので動かしてないので、違ってたらすみません。

Vueで複数選択可のチェックボックスを実装するときのエラーです。

結論を言うと、dataにあらかじめ定義してないよというエラーみたい。
dataにあらかじめ定義してなくてもよい場合と、定義してないといけない場合があるみたい。

can not set reatcive property on undefined, null, or primitive.value

<label
    v-for="(hoge, key) in hoges"
    :key = "key"
    :for = "key"
>
<input
    type="checkbox"
    v-model="hoges.hoge_id"
    :value="hoge.id"
    id="index"
>
{{ hoge.names }}

<script>

data: ~ 中略
// 定義しておく
    hoges: {
        hoge_id: []
    }


2
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0