Basic error when using jquery with nodejs

后端 未结 4 1518
情话喂你
情话喂你 2021-01-14 07:01

I\'m trying to use some jquery in my project and as soon as I tried using it I came across an error in copied code and can\'t get any google help on it

 var          


        
4条回答
  •  离开以前
    2021-01-14 07:17

    try:

    var jsdom = require("jsdom").jsdom;
    var markup = '

    Hello World!

    Heya Big World!'; var doc = jsdom(markup); var window = doc.parentWindow; var $ = require('jquery')(window) console.log($('.example').text());

    Basically you can use the jsdom module to create a DOM out of your markup and then you can use it as you would with jquery in the browser.

提交回复
热议问题