【问题标题】:Language Injection in WebStorm (scss into html)WebStorm 中的语言注入(scss 到 html)
【发布时间】:2016-07-19 15:57:18
【问题描述】:

问题:如何让WebStorm理解scss中的html

说明:

我已经存在基于vue.js的项目

我已将.vuehtml 语言相关联(.vue == .html)。

一般*.vue 文件的结构如下:

<template>
 ... 
</template>

<script>
  ...
</script>

    <style lang="scss">
      $some_var: 10px;

      .parent_class {
        .child_class {
          padding: $some_var;
        }
       }
    </style>

问题在于 WebStorm 没想到会在 html 中看到 scss(而不是纯 css)。

我知道“WebStorm”(以及“IDEA”)有language injection。 但是要理解如何正确使用语言注入对我来说有点挑战。

UPD: 看起来现在可能不可能,因为scss 是模板语言(意味着暂时不可注入):https://stackoverflow.com/a/29062183/930170

【问题讨论】:

标签: intellij-idea webstorm vue.js jetbrains-ide


【解决方案1】:

在 PhpStorm/WebStorm 2016.1 中是 supported -- LESS 和 SCSS。

但你必须使用稍微不同的语法:&lt;style rel="stylesheet/scss" type="text/css"&gt;

<style rel="stylesheet/scss" type="text/css">
  $some_var: 10px;

  .parent_class {
    .child_class {
      padding: $some_var;
    }
   }
</style>    

细微差别是:rel 属性在这里实际上是不允许的。有关更多标准投诉方法,请观看https://youtrack.jetbrains.com/issue/WEB-20921 票并加星/投票/评论它以获得任何进展的通知。 更新 -- 从 2017.1 版本开始实施。


2017 年 3 月 28 日更新适用于 IDE 的 2017.1 版本

<style type="text/scss">
  $some_var: 10px;

  .parent_class {
    .child_class {
      padding: $some_var;
    }
   }
</style>

<style type="text/stylus">
  body
    font: 12px Helvetica, Arial, sans-serif

  a.button
    -webkit-border-radius: 5px
    -moz-border-radius: 5px
    border-radius: 5px
</style>

PhpStorm/WebStorm 2017.1 中的外观如下:

【讨论】:

  • 此支持是否在 2017.1 EAP 中消失了?
  • 在我的 IDE 中不起作用,不知道为什么。它以前可以工作。 imgur.com/a/WrP85
  • @sha256 看看我的截图和代码示例——请注意type 属性。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-04-04
  • 1970-01-01
  • 1970-01-01
  • 2020-02-11
  • 2015-04-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多