Vue Loop to create id splicing Index

< div VFF = "(data,index) in arr" >

)
<canvas :id="mycanvas(index)" width="140" height="140"></canvas>

< / div >

create canvas in a loop but report _ vm.mycanvas is not a function

it"s no problem to use normal div without canvas tags

Jan.10,2022

you are prompted that the mycanvas function is missing. There are two ways to concatenate strings

the first type

 methods:{
     mycanvas(index){
       return "canvas_" +index
    }
  }

the second type

<canvas v-for="(data,index) in arr" :id="['canvas'+index]">

mycanvas is written in computed , but it will be fine if you write it in methods .

methods: {
    mycanvas (index) {
      return 'item' + index
    }
 }
Menu