js文件中书写代码没有提示的解决方案

解决方案

1、在电脑上安装node.js

node环境安装指南

下载地址: http://nodejs.cn/download/
注意: 下载长期支持版本,
![image.png](https://img-blog.csdnimg.cn/img_convert/9b989170a8f950928124e2bc6d5e4fb6.png#clientId=ud55faabd-6eeb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=138&id=uee30bcb1&margin=[object Object]&name=image.png&originHeight=172&originWidth=333&originalType=binary&ratio=1&rotation=0&showTitle=false&size=5783&status=done&style=none&taskId=ufe1f48b4-54d2-4844-88fa-16112416fb5&title=&width=266.4)

2、依赖npm把项目包初始化为npm管理的包,vscode才能识别

(1)、在项目文件中打开cmd命令

![image.png](https://img-blog.csdnimg.cn/img_convert/dac1dc26ea52049504c12aee55817dba.png#clientId=ud55faabd-6eeb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=154&id=uac548fc7&margin=[object Object]&name=image.png&originHeight=192&originWidth=766&originalType=binary&ratio=1&rotation=0&showTitle=false&size=15357&status=done&style=none&taskId=u4f711d05-a75e-40a3-b34c-539322ebe77&title=&width=612.8)

(2)、在项目文件夹中执行:npm init -y 操作

进行初始化操作
![image.png](https://img-blog.csdnimg.cn/img_convert/91ce95b8996c16dfe5557e6f19fd5f32.png#clientId=ud55faabd-6eeb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=359&id=u0495d75e&margin=[object Object]&name=image.png&originHeight=449&originWidth=847&originalType=binary&ratio=1&rotation=0&showTitle=false&size=13631&status=done&style=none&taskId=uf25d3d80-df7b-4aa4-8c02-23c3b96eaf8&title=&width=677.6)

(3)、安装jquery模块执行:npm i jquery

注意:不同的node版本,安装成功后的提示不同;到文件夹里 ----> node_modules 查看是否有jquery文件夹即可
安装成功:
![image.png](https://img-blog.csdnimg.cn/img_convert/1914eb5e89c7300d47650a83923c56b1.png#clientId=ud55faabd-6eeb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=166&id=ufe56e114&margin=[object Object]&name=image.png&originHeight=208&originWidth=654&originalType=binary&ratio=1&rotation=0&showTitle=false&size=8732&status=done&style=none&taskId=uf1ff8717-6218-411f-8ddd-0c32649375b&title=&width=523.2)
查看是否有jquery:
![image.png](https://img-blog.csdnimg.cn/img_convert/9646d98e6c30cd6faff940340029a73b.png#clientId=ud55faabd-6eeb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=166&id=q9ubO&margin=[object Object]&name=image.png&originHeight=208&originWidth=227&originalType=binary&ratio=1&rotation=0&showTitle=false&size=5360&status=done&style=none&taskId=u0e02c09b-d465-4e56-bcae-5ef653241a5&title=&width=181.6)

(4)、如果无法下载可能是没有切换中国镜像

设置中国镜像: npm set registry https://registry.npmmirror.com
查看当前镜像: npm get registry

猜你喜欢

转载自blog.csdn.net/m0_65792710/article/details/127288867
今日推荐