nodejs中使用jquery出现“jQuery requires a window with a document”错误的解决方案
来源:互联网 发布:新浪微博做淘宝客 编辑:程序博客网 时间:2024/04/24 00:33
jquery也是可以在服务端使用的,使用npm安装jquery模块即可:
$npm install -g jquery
但是实际使用时发现报了这么一个错误:jQuery requires a window with a document。
原因是默认安装jquery时,版本是最新版2.1.0,这个版本没有包括jsdom,需要额外安装一个jsdom,然后这么使用:
var jsdom = require("jsdom");
$ = require("jquery")(jsdom.jsdom().createWindow());
也可以简单地将jquery卸载掉,安装一个低版本的,如下:
$npm install -g jquery@1.6.3
这样使用起来就更加简单:
var $ = require("jquery");
var dom = $(html);
dom.find("...")"....
0 0
- nodejs中使用jquery出现“jQuery requires a window with a document”错误的解决方案
- jQuery requires a window with a document异常解决方案
- jQuery requires a window with a document
- Node jquery requires a window with a document
- [node]jQuery requires a window with a document
- 对前端js代码添加测试:Error: jQuery requires a window with a document
- jQuery使用的时候报undefined a错误的解决方案
- "Edit Document" requires a Microsoft SharePoint Foundation-compatible Application错误的解决方案
- jquery fullCalendar 显示时出现12a的解决方案
- window.opener.document.getElementById(“a”)用标准的Jquery 语言怎么写
- $.plot is not a function 和 jQuery(document)中jQuery is not a function
- jquery 中 $(document).ready() 与window.onload 的区别
- JQuery中$(document).ready() 与window.onload的区别
- 详解jquery插件中(function ( $, window, document, undefined )的作用
- Jquery中$(document).ready()与window.onload方法的区别
- 详解jquery插件中(function ( $, window, document, undefined )的作用
- Jquery中$(document).ready()和window.onload的区别
- Jquery中$(document).ready()和window.onload的区别
- 集成Lucene和HBase
- jquery学习导语
- Working Practice-把任务通过邮件发给自己
- HDU 1166 敌兵布阵 && HDU 1754 I Hate It(JAVA版)
- linux man 手册各个章节的意义和用法 .
- nodejs中使用jquery出现“jQuery requires a window with a document”错误的解决方案
- 黑马程序员------Java之转义字符
- 自定义 SharePoint 2010 快速启动栏和顶部链接栏
- 2014开启技术博客之路
- DocumentBuilder 解析出指定节点XMLString数据
- AutoMapper在MVC中的运用07
- lucene入门03
- Android学习小Demo(10)ToDoList的加强版
- JavaApplet程序