vw和px的转换
用量取的距离除以设计图的宽度
XMLHttpRequest的兼容
var request;
if(Windows.XMLHttpRequest){
request=new XMLHttpRequest();
}else{
request=new ActiveXObject("Microsoft.XMLHTTP"); //IE 5,IE6
}
npm
测试:npm -v
初始化项目:npm init -y 会产生一个package.json文件
安装模块:npm i 模块名@版本号(版本号可以不写,不写默认为最新版本) 参数
参数:-g(全局安装) --save-dev(本地安装) --save(本地安装(开发依赖))
删除模块:npm uninstall 模块名 参数
清除缓存:npm cache clear -f
nrm
安装:npm install nrm -g
查看版本号:nrm --version
查看镜像列表:nrm ls
查看nrm镜像源地址网速:nrm test
切换镜像源地址:nrm use 原名称
vue脚手架安装
运行:npm run dev
查看版本:vue -V
安装vue2.x版本
安装cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
全局安装webpack
npm install webpack -g
安装vue-cli脚手架构建工具
npm install vue-cli -g
准备一个文件夹
安装vue脚手架
vue init webpack 项目名称
除Use ESLint to lint your code选n之外,其他都选y或回车
安装项目依赖
npm i
安装vue路由模块vue-router和网络请求模块vue-resource
npm install vue-router vue-resource --save
安装vue3.x/4.x
安装
npm install -g @vue/cli 装3/4
npm install -g @vue/cli-init 桥接2
初始化开发环境
vue create 目录
打包:npm run build
卸载
//卸载3.0之前的版本
npm uninstall -g vue-cli
yarn global remove vue-cli
//卸载3.0之后的版本(可以统一使用此指令卸载)
npm uninstall -g @vue/cli
yarn global remove @vue/cli
引入组件
import 组件名 from '文件名'
安装 node.js
下载地址:https://nodejs.org/en/download/
React脚手架安装
下载
npm i -g create-react-app
查看版本
create-react-app --version
创建项目
create-react-app 项目名
启动
npm start
查看镜像地址
npm get registry
淘宝镜像
npm config set registry http://registry.npm.taobao.org/
切换回原始的
npm config set registry https://registry.npmjs.org/
解决跨域
1.找到项目目录下/node_modules/react-scripts/config/webpackDevServer.config.js
2.然后在其中找到proxy,并修改成如下:
proxy:{
"/api(可以随便写)":{
target:"请求地址",
changeOrigin:true,
"pathRewrite":{
"^/api(和上面一样)":"/"
}
}
},
3.并修改请求地址