【问题标题】:Using ES6 "import default,export default" syntax in firebase project在 Firebase 项目中使用 ES6“导入默认值,导出默认值”语法
【发布时间】:2020-10-14 00:27:23
【问题描述】:

enter image description here我使用firebase init 命令成功地将我的项目初​​始化到我的文件夹中,现在我拥有所有必要的依赖项和文件。我的问题是如何在firebase 项目中使用ES6 语法。我浏览了youtube 上的一些视频他们都在使用const .... = require('...') 语法。非常感谢。

【问题讨论】:

  • 看看here。可能会有所帮助。

标签: firebase


【解决方案1】:

要使用 ES6 功能(如 import 和 const),甚至 ES7 功能(如 await 和 async),请通过将 index.js 重命名为 index.ts 来使用 Typescript

示例 index.ts:

import * as functions from 'firebase-functions';

export const helloWorld = functions.https.onRequest((req, resp) => {
 resp.send("Hello from Firebase!");
});

【讨论】:

  • 谢谢,但我以前在 js 文件中使用这种语法,为什么现在 ts?我的意思是我总是在 React 项目中使用这种语法(我已经添加了截图)
猜你喜欢
  • 2017-06-09
  • 1970-01-01
  • 2017-07-09
  • 2023-03-15
  • 2018-10-19
  • 1970-01-01
  • 2019-09-07
  • 2017-10-07
  • 1970-01-01
相关资源
最近更新 更多