简体   繁体   English

如何分配在所有js文件功能中使用的const?

[英]how assign a const to be used in all js file functions?

Im working with 我正在与

vuex + firebase , so my vuex file has many let db = firebase.firestore() vuex + firebase ,所以我vuex文件有很多let db = firebase.firestore()

so i would like to set 'const to all file' db = firebase.firestore() 所以我想将'const to all file'设置为db = firebase.firestore()

how can i deal with this? 我该如何处理?

Where you defined db , you have to export it as follows (ES6): 在定义db ,必须按以下步骤将其导出(ES6):

export const db = firebase.firestore();

Then you will be able to use it in your JS files by simply calling it 然后,您只需调用它即可在JS文件中使用它

import db from 'your path'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM