The problem of variable splicing in vue data

        data{
            return{
                successData1: [],
                failData1: [],
                dataTime1: {},

                successData2: [],
                failData2: [],
                dataTime2: {},

                successData3: [],
                failData3: [],
                dataTime3: {},

                successData4: [],
                failData4: [],
                dataTime4: {}
            }
       }
                        let dataModel = (id, i) => {
                            let j=i+1
                            echarts.init(document.getElementById(id + i)).setOption({
                                tooltip: {
                                    trigger: "axis",
                                    axisPointer: {            
                                        type: "shadow"     
                                    }
                                },
                                legend: {
                                    data: ["", ""]
                                },
                                grid: {
                                    left: "3%",
                                    right: "4%",
                                    bottom: "3%",
                                    containLabel: true
                                },
                                yAxis: {
                                    type: "value"
                                },
                                xAxis: {
                                    type: "category",
                                    data: this.dataTime+j[i]   <----
                                },
                                series: [
                                    {
                                        name: "",
                                        type: "bar",
                                        stack: "",
                                        label: {
                                            normal: {
                                                show: true,
                                                position: "insideRight"
                                            }
                                        },
                                        data:this."successData"+j[i] <----
                                    },
                                    {
                                        name: "",
                                        type: "bar",
                                        stack: "",
                                        label: {
                                            normal: {
                                                show: true,
                                                position: "insideRight"
                                            }
                                        },
                                        data: `this.failData${j}[${i}]` <----
                                    }
                                ]
                            });
                        }
                        
              
             for (let i = 0; i < this.channelInfoSave.length; iPP) {
                  dataModel ("XXXid",i)
             }

since there are several similar diagrams, I came up with a method independently, but how do you spell this variable? None of the attempts I wrote above are correct

Mar.29,2021

data: this['successData'+j][i]

use template string

data: this[`successData${j}`][i]

since there are similar diagrams, why don't you write them as components reference


splice like this:

`${this.dataTime[j][i]}`

it is recommended to have a good understanding of the basics of js and the template string of es6.

I hope my answer can help you, thank you.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b86c-2afe3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b86c-2afe3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?