I am practicing node-webkit as a nodejs beginner.
My main page is a simple html page including a main.js script
I've installed jquery using npm install jquery
index.html
<!-- index.html -->
...
<script src="js/main.js"></script>
</head>
<body>
<div id="demo">Hi! </div>
</body>
</html>
main.js
// main.js
const $ = require('jquery')
$(document).ready(function () {
$('#demo').click(function () {
$(this).text($(this).text() + 'Hi! ')
})
})
If I load jquery in my index.html like <script src="path/to/jquery.js"></script> it works well, but if I require jquery in my main.js it doesn't!
I've already tested:
main.jsis properly including and working with native js methods (likedocument.getElementById('demo').onclick = ...)- Other node modules or libraries such as
vue,lodashor natives likefs,urlwork well. So require function works good. - While I'm requiring jquery as above, inline
<script>s doesn't work as well.
I don't know if it's because of node-webkit or something else I'm missing?
via ShahinSorkh
No comments:
Post a Comment