簡體   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