简体   繁体   中英

internet explorer wont read object attributes

The commented out section does not work in IE, But does work in the other browsers.

IE errors on [query.outFields[1]] claiming it needs a string or a number. Any ideas why? Any ideas to how get IE to work with those commented lines?

                             var attS = 
                            {
                                //[query.outFields[1]]: pin, 
                                //[query.outFields[0]]: vars[0], 
                                //[query.outFields[2]]: vars[5], 
                                //[query.outFields[3]]: vars[6],
                                PIN: pin, 
                                APN: vars[0], 
                                PARCELAREA: vars[5], 
                                AREATYPE: vars[6],
                                PARCELVER:working[0],
                                PERMITNUM:working[1],
                                ADDRESSID:working[2]
                            } 

Here is the whole code block if you think it'll help..

                for(j =0;j<multiPermit.length;j++)
                {
                    var vars = multiPermit[j];
                    console.log(vars);
                    //center X
                    var x = vars[2];
                    //center Y
                    var y = vars[3];                                                
                    var pin = vars[4];
                    //console.log(pin);

                    //Delete source geometry for multi point from final data to ensure it's not represented twice.
                    for(l=0;l<inputInfo.data.length;l++)
                    {
                        temp = inputInfo.data[l];
                        if(temp.attributes[query.outFields[0]]==vars[0] && temp.x == x && temp.y==y)
                        {
                            inputInfo.data.splice(l,1);
                        }                              
                    }                        

                    //var Test=query.outFields[1];
                    //console.log(Test);
                    for(var i=0; i<zipArray.length;i++)
                    {
                        var working = zipArray[i];
                        if(working[0]==vars[0])
                        {          
                            var quickPush=inputInfo.data    

                            var newX = x;
                            var newY = y;


                             var attS = 
                            {
                                //[query.outFields[1]]: pin, 
                                //[query.outFields[0]]: vars[0], 
                                //[query.outFields[2]]: vars[5], 
                                //[query.outFields[3]]: vars[6],
                                PIN: pin, 
                                APN: vars[0], 
                                PARCELAREA: vars[5], 
                                AREATYPE: vars[6],
                                PARCELVER:working[0],
                                PERMITNUM:working[1],
                                ADDRESSID:working[2]
                            } 

                            //console.log(attS);
                            quickPush.push({"x": newX,"y": newY,"attributes": attS})
                        }
                    }
                }                                        

Computed property names ( { [likeThis]: "here" } ) are a new feature in EcmaScript 6 and are not supported by Internet Explorer yet.

You'll need to create your object and then add your variable fields afterwards.

 var attS = {
   PIN: pin,
   APN: vars[0],
   PARCELAREA: vars[5],
   AREATYPE: vars[6],
   PARCELVER: working[0],
   PERMITNUM: working[1],
   ADDRESSID: working[2]
 };
 attS[query.outFields[1]] = pin;
 // etc

I'm not 100% if I get your problem, but I think you're mixing 2 ways of defining properties of an object in javascript.

You are trying

var myObject = {
   prop1 : value,
   prop2 : value,
   [prop3nameWhichIsPartOfOtherVar]: value
}

This is not possible (yet) on Internet explorer. A way to go around this is simply adding:

myObject[prop3nameWhichIsPartOfOtherVar] = value; 

After your definition.

More information about what works or doesn't work (and the browser compatibilities): here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM