我正在尝试从typescript函数调用javascript函数。 这根本不起作用。
我已经在stackblitz中创建了sudo代码。请检查相同。
答案 0 :(得分:2)
您可以将其导出到一个地方,将其导入到另一个地方。
hello.js
export function hello() {
console.log('hello world');
}
app.component.ts
import { hello } from '../external/hello.js';
@Component({
// ...
})
export class AppComponent {
buttonClick() {
console.log('btn click called. 1.');
hello();
console.log('btn click called. 2.');
}
}