代码之家  ›  专栏  ›  技术社区  ›  Donovant

为什么在使用Visual Studio代码将对象扩展导入其他文件后,无法看到任何代码完成?

  •  0
  • Donovant  · 技术社区  · 7 年前

    正如标题中已经解释的那样,在导入对象扩展后,我看不到任何代码完成

    • 文件格式。js:

      import EmberObject from '@ember/object'; 
      
      const Form = EmberObject.extend({
              isTouched: false,
              isValid: false,
              errors: null,
              value: null,
              init() {...},
              getSomething(){ ... }  
      }
      
    • 文件组件。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]         
       });
      }
      

    在组件的这一点上。当我打字的时候 这类型 编辑器(VSC)没有给我任何关于表单类/对象的真正建议

    猜猜看?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Donald Wasserman    7 年前

    不幸的是,编辑很难理解余烬对象。

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

    下面是一篇关于如何开始的oveview文章: https://medium.com/build-addepar/es-classes-in-ember-js-63e948e9d78e

    TL:DR;是

    1. 安装余烬装饰器 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();

    推荐文章