繁体   English   中英

使用Visual Studio Code将EmberObject扩展名导入到其他文件中后,为什么看不到任何代码完成?

[英]Why cannot see any code completion after imported an EmberObject extension into a different file, using Visual Studio Code?

如标题中已经解释的,导入EmberObject扩展名后看不到任何代码完成

  • 文件form.js:

     import EmberObject from '@ember/object'; const Form = EmberObject.extend({ isTouched: false, isValid: false, errors: null, value: null, init() {...}, getSomething(){ ... } } 
  • 文件component.js

     import Form from '../../classes/form'; init() { this._super(arguments); // console.log(this.elementId); this.form = Form.create({ email: [this.email, Validators.required, Validators.email], password: [this.password, Validators.required] }); } 

此时,当我键入this.form时,在component.js中 编辑器(VSC)在Form类/ EmberObject上没有给我任何真正的建议

有猜到吗?

不幸的是,Ember对象使编辑人员难以理解。

但是,您可以使用本机类,这将改善您的编辑器体验!

这是有关如何进行的oveview文章: https ://medium.com/build-addepar/es-classes-in-ember-js-63e948e9d78e

TL:DR;

  1. 安装Ember装饰器https://github.com/ember-decorators/ember-decorators
  2. 使用本机类

在您的示例中

import EmberObject from '@ember/object'
export default class FormClass extends EmberObject {
  constructor() {
    // replaces init
    super();
  doStuff() { }

后来让form = new FormClass();

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM