【发布时间】:2015-10-11 12:39:44
【问题描述】:
我将 JSHint 和 SublimeLinter 与 Sublime Text 3 一起使用,但是当使用 Facebooks API 时,它不喜欢结构中的对象 double :,例如。 { og:url: 'example.com' }
FB.api(
'me/objects/my-app:object',
'post',
{
og:url: http://samples.ogp.me/12345678910,
og:title: Sample Object,
og:type: my-app:object,
og:image: https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png,
og:description: ,
fb:app_id: 12345678910,
place:location:latitude: Sample Location: Latitude,
place:location:longitude: Sample Location: Longitude
},
function(response) {
// handle the response
}
);
我知道如何忽略项目根目录中 .jshintrc 文件中的某些变量和名称,但不知道如何阻止它抱怨这种结构。我认为由于 Facebook API 很受欢迎,因此值得在这里发布。
【问题讨论】:
-
这行得通吗?因为这肯定不是正确的 javascript/json。
-
这是 Facebook 在开发人员工具中生成的示例代码 - 所以我猜测它的正确语法。 facebook 查找的页面上的示例标记是
<meta property="og:url" content="https://example.com/path" />
标签: facebook-graph-api facebook-opengraph jshint sublimelinter