简体   繁体   English

Vue 文件不使用 javascript 方法显示智能感知

[英]Vue files dont show intellisense with javascript methods

I am running Vue 2.6 and using VSCode and my intellisense works just fine within js files, but once I try to use the intellisense from within a vue file, I lose all my intellisense.我正在运行 Vue 2.6 并使用 VSCode,而我的智能感知在 js 文件中工作得很好,但是一旦我尝试从 vue 文件中使用智能感知,我就会失去所有的智能感知。

I have the latest VSCode install and Vetur installed for working with Vue files.我安装了最新的 VSCode 和 Vetur 来处理 Vue 文件。

index.js - This is an npm package of mine that i am importing into my Vue app. index.js - 这是我的 npm package,我正在导入到我的 Vue 应用程序中。

class MyClass {
  /**
   * 
   * @param {string} str - ID of the DOM node to attach to.
   * @param {boolean|Object} opt - Other options stuff here....
   */
  constructor(str, opt) {}
}

export default MyClass;

new MyClass('abc', {}); <------ intellisense works here.

Page.vue页面.vue

<!--- all vue template code here -->

<script>
  import MyClass from 'my-npm-package'; // This is the index.js file from my npm package.

  new MyClass(); <--------------- intellisense doesnt work here ever..

  export default {
    mounted() {
      new MyClass(); <--------------- intellisense doesnt work here either.. 
    }
  }
</script>

You need plugin for VS Code to recognize Vue syntax你需要 VS Code 的插件来识别 Vue 语法

For Vue versions 2.x plugin is Vetur对于 Vue 版本 2.x 插件是Vetur

For Vue versions 3.x plugin is Vue Language Features (Volar)对于 Vue 版本 3.x 插件是Vue 语言功能 (Volar)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果php不显示javascript - dont show javascript in if php 是否有任何JavaScript IDE能够在IntelliSense中显示所有使用过的对象字段和方法? - Is there any JavaScript IDE that's able to show all used objects fields and methods in IntelliSense? 在单独的解决方案中智能感知JavaScript和CSS文件 - Intellisense for JavaScript and CSS files in separate solution VS2008中用于外部javascript文件的Intellisense - Intellisense for external javascript files in VS2008 为什么Visual Studio intellisense不显示XMLHttpRequest对象方法? - Why Visual Studio intellisense doesn't show XMLHttpRequest objects methods? 如果是星期日,JavaScript 日历不显示第一个月 - JavaScript calendar dont show the first of month if is sunday Javascript中的Visual Studio和XML注释使“公共”方法在智能感知中消失 - Visual Studio and XML Commenting in Javascript makes “public” methods disappear in intellisense 在Razor视图中引用JavaScript文件以获取JavaScript Intellisense - Referring to JavaScript files in Razor views to get JavaScript Intellisense JavaScript调用show hide方法 - JavaScript calling show hide methods 引用javascript嵌入式资源但智能感知不会显示任何内容 - Referencing javascript embedded resource but intellisense doesn't show anything
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM