Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
749 views
in Technique[技术] by (71.8m points)

sublime 运行js文件window is not defined

在sublime text中运行js代码,其中代码用到window、document对象

ctrl+b运行的时候,提示window is not defined
为什么呢?前端小白求告知


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

这里的运行实际是运行的 node, window 属于浏览器环境中的全局变量,在 node 中肯定拿不到的.可以改成 global


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...