首页 > 解决方案 > VS 中异步函数关键字下的 extjs 警告/错误

问题描述

在 Visual Studio 版本 14.0.25431.01 Update 3 中,我转到 FILE,NEW SENCHA PROJECT。在 MainController.js 中,我添加了一个简单的异步函数。我收到了来自我的 IDE 的警告,在 function 一词下有一条红线,表示“expected ';'”。代码仍然正常运行,但我试图摆脱这个错误/警告。有谁知道我该如何解决这个问题?

/**
 * This class is the controller for the main view for the application. It is 
specified as
 * the "controller" of the Main view class.
 */
Ext.define('ExtApplication1.view.main.MainController', {
  extend: 'Ext.app.ViewController',

  alias: 'controller.main',

  onItemSelected: function(sender, record) {
    Ext.Msg.confirm('Confirm', 'Are you sure?', 'onConfirm', this);
  },

  onConfirm: function(choice) {
    if (choice === 'yes') {
      //
      foo();
    }
  }
});

async function foo() {
  try {
    console.log(`Got the final result:`);
  } catch (error) {
    //failureCallback(error);

  }
};

红色错误行位于功能词下方,靠近 async foo

标签: visual-studiofunctionextjsasync-await

解决方案


推荐阅读