gpt4 book ai didi

compiler-errors - 我如何/在哪里告诉编译器使用 ecmascript 6

转载 作者:行者123 更新时间:2023-12-04 06:58:00 25 4
gpt4 key购买 nike

我想要完成的事情:

为什么:

  • 创建 Rich CardSERP 中展示

问题:

尝试创建 User-Defined Variable 时以及 Tag 使用的脚本本身。使用 Preview and Debug 时GTM的特点。我收到以下错误:

this language feature is only supported for ECMASCRIPT6 mode or better: let declaration. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT to enable ES6 features.

我明白...或者至少我认为我明白我需要告诉编译器

Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT

但是我该如何实现呢?

<script>
(function(){
// ==ClosureCompiler==
// @compilation_level SIMPLE_OPTIMIZATIONS
// @output_file_name default.js
// @language_in=ECMASCRIPT6_STRICT;
// @language_out=ES5_STRICT;
// ==/ClosureCompiler==

"use strict";
let data = {
"@context": "http://schema.org",
"@type": "MovingCompany",
"name": "WDA Movers",
"logo" : {
"@type" : "ImageObject",
"url" : "http://wda-moving.online/images/logo.jpg",
"height" : 435,
"width" : 361
},
"address": {
"@type": "PostalAddress",
"addressLocality": "Eugene",
"addressRegion": "OR",
"postalCode": "97404",
"streetAddress": "411 Heywood Avenue"
},
"openingHours": "Mo-Su 7:00-23:30",
"priceRange": "$$$",
"telephone": "(541) 255-9876",
"url": "http://wda-moving.online",
"sameAs" : [
"https://www.facebook.com/wda.movers/",
"https://plus.google.com/+WDAMoversEugene/about?gmbpt=true&hl=en"
],
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": {{YELP_rating}},
"reviewCount": {{YELP_review_count}},
"bestRating": "5",
"worstRating": "1"
},
"review": {
"@type" : "Review",
"author" : {{YELP_reviews_user_name}},
"reviewBody" : {{YELP_reviews_excerpt}},
"reviewRating" : {
"@type": "Rating",
"ratingValue": {{YELP_reviews_rating}}
}
}
}
let richCard = document.createElement('script');
richCard.type = "application/ld+json";
richCard.innerHTML = JSON.stringify(data);
document.getElementsByTagName('head')[0].appendChild(richCard);
})(document);
</script>

如您所见,我已尝试将以下内容添加到上面的脚本中:

// ==ClosureCompiler==
// @compilation_level SIMPLE_OPTIMIZATIONS
// @output_file_name default.js
// @language_in=ECMASCRIPT6_STRICT;
// @language_out=ES5_STRICT;
// ==/ClosureCompiler==

"use strict";

这没有用...任何人都可以帮助我吗?

最佳答案

如果你看一下 asset-pipeline plugin ,您将找到以下 build.gradle 示例:

assets {
minifyJs = true
minifyCss = true
enableSourceMaps = true
configOptions = [:]

minifyOptions = [
languageMode: 'ES5',
targetLanguage: 'ES5', //Can go from ES6 to ES5 for those bleeding edgers
optimizationLevel: 'SIMPLE',
angularPass: true // Can use @ngInject annotation for Angular Apps
]
// ... snip ...
}

当我将 minifyOptions 中的 languageMode 设置为 'ES6' 时,错误消失并且在部署时提供正确的 JavaScript。当然,您也可以将 assets.minifyJs 设置为 false 以获得相同的效果。

关于compiler-errors - 我如何/在哪里告诉编译器使用 ecmascript 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38961315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com