Hi there:
It seems a trivial issue but I'm stuck and don't know why:
I'm using Import/Export in two my JavaScript files. For simplicity sake ...the "mother"js.file has a function
export function ShowAlert(val) {
alert(val);
}
There isa razor view ( cshtml file) that refers to the "mother" js file above as follows:
<script type="module" src="~/js/mother_file.js"></script>
Now...this cshtml file which is a view in my project, refers also to an external script that for simplicity sake I name child.js file. Up to this point, my script section of my cshtml file reads
<script type="module" src="~/js/mother_file.js"></script>
<script type="module" src="~/js/child_file.js"></script>
My understanding is that when I render the view ( open the cstml file) the mother and child js files talk to each other ...am I correct?
So in the child_file.js I refer to the ShowAlert function that is in the mother_file as follows:
$(document).ready(
function () {
import ShowAlert from './js/mother_file.js
})
When I run the project, the browser complains that the function isn't there with an Unexpected identifier error.
What I'm doing wrong?
Thanks