Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to export multiple variables in vuejs

Tags:

vue.js

I started creating a web app with the firebase database. The firebase config is in a separate file that gets imported into the application.

Now I want to add firebase storage, but I can't seem to export both db and st. I get an error message saying that vuejs doesn't support named exports. I would export app instead and get rid of the db and st references, however my application already has tons of references to db. Is there a simple way to export db and st?

const app = Firebase.initializeApp(config);
const db = app.database();
const st = app.storage();  //this was recently added

export default db;  //How do I add 'st' to the export in vuejs?
like image 689
gvon79 Avatar asked Nov 15 '17 14:11

gvon79


1 Answers

In order to achieve what you want,

you can export an object with db and st as properties, or export different variables.

this syntax is called ES6, which use modules. you can read more about them here (2ality blog) and here (MDN).

You can try:

export { db, st };

or

export const db = app.database();
export const st = app.storage();

Then, import them wherever you want.

import { db, st } from 'path/to/file'
like image 92
Eyal Cohen Avatar answered Oct 23 '22 01:10

Eyal Cohen