我使用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>
答案 0 :(得分:3)
Make sure that Vue.js plugin is enabled in Preferences | Plugins - it is bundled with recent WebStorm versions. If it's installed and enabled, make sure that *.vue
extension is assigned to Vue.js Templates in Preferences | Editor | File Types, and that your don't have App.vue
pattern registered for Text file type there
答案 1 :(得分:1)
首先,在Preferences | Plugins
中添加Vue.js插件。
然后你应该
转到:WebStorm - &gt;偏好 - &gt;编辑 - &gt;文件类型 - &gt; HTML:
Registered Patterns
中的没有*.vue
。
在*.vue
中添加Registered Patterns
,如下所示:
然后应用它。