我有以下 .js
文件,Dreamweaver 在第 2 行报告语法错误。
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": 0,
"properties": {
"Id": 0,
"Title": "River & Trail HQ",
"Other": null,
"Parking": "Yes"
},
"geometry": {
"type": "Point",
"coordinates": [
-8649997.6690437607,
4769179.73322534
]
}
}
]
}
好像有问题
"type": "FeatureCollection",
线。
最佳答案
如果这是整个 JavaScript 文件,那么它会给您一个错误,因为它被解释为 block 而不是对象文字。要解决此问题,您可以将其分配给某些内容,例如
var someObj = {
"type": "FeatureCollection",
...
}
您可能还会考虑 JSON 文件(可能就是这种情况,因为自由 float 的对象文字无论如何也不会给您带来多大好处)。 JSON 和 JavaScript 不一样。如果您确实需要 JSON 文件,请将其保存为这样的文件 (.json
)。
关于javascript - JS 脚本语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19506204/