WebStorm 无法识别 .vue 文件

qg_*_*137 4 webstorm

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

enter image description here

代码如下:

<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>
Run Code Online (Sandbox Code Playgroud)

air*_*aft 6

首先,在.Preferences | Plugins

那么你应该

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

在此输入图像描述

中Registered Patterns没有*.vue。

*.vue像这样添加Registered Patterns:

在此输入图像描述

然后应用它。


len*_*ena 5

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