WebStorm 无法识别 .vue 文件

The WebStorm do not recognise .vue file

我用Vue-CLI创建了一个Vue项目,当我用WebStorm打开项目时,.vue文件看起来像纯文本,没有高亮语法。

代码如下:

<template>
  <div id="app">
    <img src="./assets/logo.png">
    <h1>{{ msg }}</h1>
    <h2>Essential Links</h2>
    <ul>
      <li><a href="https://vuejs.org" target="_blank">Core Docs</a></li>
      <li><a href="https://forum.vuejs.org" target="_blank">Forum</a></li>
      <li><a href="https://chat.vuejs.org" target="_blank">Community Chat</a></li>
      <li><a href="https://twitter.com/vuejs" target="_blank">Twitter</a></li>
    </ul>
    <h2>Ecosystem</h2>
    <ul>
      <li><a href="http://router.vuejs.org/" target="_blank">vue-router</a></li>
      <li><a href="http://vuex.vuejs.org/" target="_blank">vuex</a></li>
      <li><a href="http://vue-loader.vuejs.org/" target="_blank">vue-loader</a></li>
      <li><a href="https://github.com/vuejs/awesome-vue" target="_blank">awesome-vue</a></li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'app',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App'
    }
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}

h1, h2 {
  font-weight: normal;
}

ul {
  list-style-type: none;
  padding: 0;
}

li {
  display: inline-block;
  margin: 0 10px;
}

a {
  color: #42b983;
}
</style>

首先,在Preferences | Plugins中添加Vue.js插件。

那你应该

转到:WebStorm -> 首选项 -> 编辑器 -> 文件类型 -> HTML:

Registered Patterns中没有*.vue

像这样在 Registered Patterns 中添加 *.vue

然后应用它。

确保 Vue.js 插件在 首选项中启用 | Plugins - 它与最近的 WebStorm 版本捆绑在一起。如果已安装并启用,请确保将 *.vue 扩展分配给 Vue.js 模板 中的 首选项 |编辑|文件类型,并且您没有为文本文件类型注册App.vue模式