search

Home  >  Q&A  >  body text

javascript - typescript 给变量赋值namespace里面的枚举值报错

// index.ts

/// <reference path="./enum.ts" />

const a = common.Country.CN;
// enum.ts
namespace common {
    export enum Country {
        CN = 0,
        US = 1,
    }
}

用ts-loader编译后总报错:

Uncaught ReferenceError: common is not defined

求解,为什么总是报未定义啊? 我头部已经声明了enum.ts了啊

阿神阿神2788 days ago608

reply all(0)I'll reply

No reply
  • Cancelreply