Ego*_*tov 19 import export const typescript
有谁可以帮助我吗
我有2个文件main.ts和hi.ts
hi.ts:
export const hello = "dd";
Run Code Online (Sandbox Code Playgroud)
main.ts:
import { hello } from "./hi";
...
class A {
public sayHello() {
console.log("hello=" + hello);
}
...
}
Run Code Online (Sandbox Code Playgroud)
我有例外:
未捕获的ReferenceError:未定义hello(...)
如何从A类中看到这个const变量?可能吗?
Soc*_*lai 19
我的回答是指Typecript 2+.
// 1.ts
export const AdminUser = { ... }
// index.ts
import * as users from './docs/users/admin';
var adminUser = users.AdminUser;
Run Code Online (Sandbox Code Playgroud)
b/w你的代码和我的唯一区别是import语句中的*运算符.
| 归档时间: |
|
| 查看次数: |
28696 次 |
| 最近记录: |