I bought a HTML template, it includes two JS files, theme.js and plugins.js.
I can’t import them into my project, i tried so many things i found on internet but none of them worked.
here is my theme.js file:
'use strict';
var theme = {
init: function () {
theme.stickyHeader();
theme.subMenu();
theme.offCanvas();
//there are more functions
},
stickyHeader: () => {
var navbar = document.querySelector(".navbar");
if (navbar == null) return;
// codes
}
// other functions
}
theme.init();
plugins.js file is something like that:
plugins.js
so, there are many pages and i break them into the component pieces. I want to import JS files and make it work in all .vue files.
in theme.js file, i tried export default theme;
and in app.vue,
> import theme from '~/assets/js/theme.js';
>
> onMounted(() => {
> theme.init();
> });
It didn’t work.