【问题标题】:Sublimelinter & JSHint complaining about Facebook's Open Graph objects {og:url: "example.com"}Sublimelinter 和 JSHint 抱怨 Facebook 的 Open Graph 对象 {og:url: "example.com"}
【发布时间】: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


【解决方案1】:

用引号括起来。 例如。 { 'og:url': 'example.com' }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-11
    • 2015-01-20
    相关资源
    最近更新 更多