最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ecmascript 6 - How to get Webstorm 11 to recognize ES2015 javascript in HTML script tags - Stack Overflow

programmeradmin3浏览0评论

I've been having trouble getting WebStorm 11 to recognize/highlight/parse ES6/ES2015 javascript when it's inside script tags in regular HTML. Can't find a setting that seems to apply to this. Thanks in advance for your time.

For example, the following js is inside a script tag. You'll notice that WebStorm thinks that a whole bunch of things are broken with it, but it executes just fine.

I've been having trouble getting WebStorm 11 to recognize/highlight/parse ES6/ES2015 javascript when it's inside script tags in regular HTML. Can't find a setting that seems to apply to this. Thanks in advance for your time.

For example, the following js is inside a script tag. You'll notice that WebStorm thinks that a whole bunch of things are broken with it, but it executes just fine.

Share Improve this question edited Jan 12, 2016 at 6:39 Alexander Mikhalchenko 4,5654 gold badges35 silver badges57 bronze badges asked Nov 15, 2015 at 17:39 caybloodcayblood 1,8761 gold badge25 silver badges46 bronze badges 1
  • Fixed a similar situation by changing the Javascript Language Version to ES6 under settings -> Languages & Frameworks -> Javascript – dwbartz Commented Sep 29, 2016 at 11:52
Add a ment  | 

1 Answer 1

Reset to default 19

Using <script type="text/ecmascript-6"> rather than <script type="text/javascript"> should help you.

Issue on JetBrans YouTrack on the topic.

UPD:

It looks like a WebStorm bug (tested on the latest release):

  var a = (d) => {}; //OK
  a.v('c', (d) => {}); // OK
  class Test {
    doSmth(){
      a.sh('ff', (d) => {});
      //            ^^^^^^ , or ) expected when in <script>
      //            100% OK when in a js file
    }
  }

I think you could contact JetBrains support, probably they will fix it.

But anyways, I do not think it's a good practice to have JS in your HTML and, moreover, ES6 which is not yet monly supported.

UPD 2:

As posted in ments by, zigomir, you might want to use type="text/babel" instead of type="text/ecmascript-6" in .vue files or otherwise linting wouldn't work.

发布评论

评论列表(0)

  1. 暂无评论