0

Missing "use strict" statement即使它贴在文件顶部,我也会得到这个,这让我感到困惑。对于第 10 行和第 12 行,此错误出现两次。

'user strict';
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
  host : 'http://localhost:9200'
});
client.search({
  index: 'twitter',
  type: 'tweets'
}).then(function (resp) {
  var hits = resp.hits.hits;
}, function (err) {
  console.trace(err.message);
});

上面的代码主要是从http://www.fullscale.co/elasticjs/复制和粘贴的

4

1 回答 1

5

看来你打错了。

它应该是

'use strict';

如果您想了解更多关于“使用严格”、如何使用它以及它的实际作用,您可以查看以下页面:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

于 2015-12-04T12:53:17.883 回答