Answer the question
In order to leave comments, you need to log in
How to call an imported function in js?
It is necessary to transfer the function for the condition from the first js file to the second file.
The first theme.js
file has the following code:
export let DarkTheme = () => {
/*Переключение на темную тему*/
$('#darkTheme').css({'display' : 'block'})
$('#lightTheme').css({'display' : 'none'})
}
export let DarkTheme = () => {
/*Переключение на светлую тему*/
$('#darkTheme').css({'display' : 'none'})
$('#lightTheme').css({'display' : 'block'})
}
header.js
:import {DarkTheme, LightTheme} from './theme'
if (window.location.pathname == '/' || window.location.pathname == '/list') {
if (localStorage.getItem('themeStyle') === 'dark') {
/*здесь по идее мне нужно вызвать функции с первого файла, чтобы проверить условие - какая сейчас выбрана тема*/
}
else {
//
}
}
Answer the question
In order to leave comments, you need to log in
theme.js
function DarkTheme() {}
function LightTheme() {}
export {LightTheme, DarkTheme}
import {DarkTheme, LightTheme} from './theme'
LightTheme()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question