DWQA QuestionsCategory: ProgramCan't the label in the iView checkbox be traversed
come on. asked 4 months ago

<style type=”text/css”>
</style>
<template>

<div class="changeMenu">
    
   

     <CheckboxGroup  @on-change="handle123($event)">
        <Checkbox v-for="item1 in item"  label="{{item.check}}"  >
            <span>{{item1.title}}</span>
            <span>{{item1.message}}</span>
        </Checkbox>
    </CheckboxGroup>
     
  
   

</div>

</template>
<script>
import axios from ‘axios’;
export default{

name:'changeMenu',
        data(){
            return{
                
                item:[
                        {
                            Title: 'first item',
                            Message: 'first item description',
                            check:"000"
                        },
                        {
                            Title: 'first item',
                            Message: 'first item description',
                            check:"001"
                    }
                ],
                
                
            }
        },
        methods:{
            handleAddUser () {
            
            },
            cancel () {
                
            },
            handle123($event){
                console.log($event)
            }
    
    }
      
}

</script>
Then an error is reported when using. Can’t label be added by traversal,: label = “Item1. Check”: key = “Item1. Check (index can be filled in)”
V-bind abbreviation for binding:,:label=”item.check”,<CheckboxGroup v-model=”checkAllGroup” @on-change=”checkAllGroupChange”>

        <template v-for="item in checkArr">
          <Checkbox :label="item.name">{{ item.name }}</Checkbox>
        </template>
    </CheckboxGroup>
toBeTheLight replied 4 months ago

What is an error report? No key? Cannot use template?

toBeTheLight replied 4 months ago

label=”{{item.check}}”: Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div id=”{{ val }}”>, use <div :id=”val”>.

3 Answers
Little fish with small eyes answered 4 months ago

: label = “Item1. Check”: key = “Item1. Check (index can be filled in)”
V-bind abbreviation for binding:

Rabbits like pears answered 4 months ago

:label=”item.check”

Little raccoon answered 4 months ago

<CheckboxGroup v-model=”checkAllGroup” @on-change=”checkAllGroupChange”>

        <template v-for="item in checkArr">
          <Checkbox :label="item.name">{{ item.name }}</Checkbox>
        </template>
    </CheckboxGroup>