当前位置: 首页 > news >正文

从零开始学网站建设知乎北京搜索引擎推广服务

从零开始学网站建设知乎,北京搜索引擎推广服务,滕州市建设局网站,建筑材料采购网站❀官网 1、安装脚手架:npm install -g create-react-app 2、查看版本:create-react-app -V !!!注意 Node版本必须是14以上,不然会报以下错误。 3、创建react项目(项目名不能包含大写字母&…

官网

1、安装脚手架:npm install -g create-react-app

2、查看版本:create-react-app -V

!!!注意 Node版本必须是14以上,不然会报以下错误。

在这里插入图片描述

3、创建react项目(项目名不能包含大写字母):npx create-react-app <项目名称>

  • npx 是 npm 5.2+ 附带的 package 运行工具。
  • create-react-app 创建的项目默认无法看到 webpack 的相关配置,如果想要配置 webpack,需要执行 npm run eject命令

4、运行 react 项目:npm start

5、react中使用video标签显示本地视频不生效问题:

使用require进行引入路径即可。

<video className="videoStyle" src={require('./video/3.mp4')} autoPlay muted loop></video>

6、重写脚手架的配置(参考链接):

  • tips: react-app-rewired@2.x 版本需要搭配 customize-cra 使用。
  • 安装: npm i react-app-rewired customize-cra --save-dev
  • 在根目录下新建文件config-overrides.js,写入代码:
    module.exports = function override(config, env) {return config
    }
    
  • 重写package.json中的配置:
    在这里插入图片描述

7、react项目本地代理:

  • create-react-app脚手架若在2.0版本以下
    • 直接在package.json中配置:
      "proxy":{"/api":{"target":"http://127.0.0.1:3000",  # 代理地址"changeOrigin": true,  # 是否允许跨域"pathRewrite": {  # 重写路径"^/api": "/"},}
      }
      
  • create-react-app脚手架若在2.0版本以上配置一个代理:
    • 直接在package.json中配置:
      "proxy": 'http://127.0.0.1:3000' # 只能是字符串
      
  • create-react-app脚手架若在2.0版本以上配置多个代理:
    • 安装 http-proxy-middlewarenpm i http-proxy-middleware --save-dev
    • 在 src 的根目录下新建文件 setupProxy.js(文件名称固定,不能更改),写入代码:
      // http-proxy-middleware V1.0版本以下使用:const proxy = require('http-proxy-middleware')module.exports = function(app) {app.use(proxy('/api', {target: 'http://localhost:3000/',changeOrigin: true,// pathRewrite: {//   '^/api': ''// }}))}// http-proxy-middleware V1.0版本以上使用:const { createProxyMiddleware } = require('http-proxy-middleware');module.exports = function (app) {app.use(createProxyMiddleware('/api', {target: 'http://127.0.0.1:3000',secure: false,    # 指定Cookies能否被用户读取changeOrigin: true,pathRewrite: {"^/api": "/"},}),createProxyMiddleware('/api1', {target: 'http://127.0.0.1:3001',secure: false,    # 指定Cookies能否被用户读取changeOrigin: true,pathRewrite: {"^/api1": "/"},}));};
    

8、配置多环境打包(官网文档):

  • 安装 dotenv-cli :npm i dotenv-cli -D
  • 新建环境文件,并且写入路径:路径必须以 REACT_APP 开头在这里插入图片描述
  • 修改 package.json 中的 scripts来指定环境:
    在这里插入图片描述
  • 执行 npm run build:dev 即可
  • index.html文件中使用:%REACT_APP_URL_API%
  • js/jsx文件 中使用:process.env.REACT_APP_URL_API

9、打包上线后,静态资源css和js报404:

  • 需要在package.json文件中添加"homepage": "./"进行重新打包即可。
    在这里插入图片描述

文章转载自:
http://dinncodickeybird.ssfq.cn
http://dinncokinaestheses.ssfq.cn
http://dinncoidleness.ssfq.cn
http://dinncofelon.ssfq.cn
http://dinncokordofan.ssfq.cn
http://dinncoimpassivity.ssfq.cn
http://dinncogalactokinase.ssfq.cn
http://dinncosecund.ssfq.cn
http://dinncovinylidene.ssfq.cn
http://dinncospacecraft.ssfq.cn
http://dinncovitellogenous.ssfq.cn
http://dinncoheadspring.ssfq.cn
http://dinncohaptometer.ssfq.cn
http://dinncofastidiously.ssfq.cn
http://dinncocryoextractor.ssfq.cn
http://dinncoreligionism.ssfq.cn
http://dinncoimmune.ssfq.cn
http://dinncoseram.ssfq.cn
http://dinncogabrovo.ssfq.cn
http://dinncoshillaber.ssfq.cn
http://dinncotinner.ssfq.cn
http://dinncoinsanely.ssfq.cn
http://dinncophrenologist.ssfq.cn
http://dinncoaerotaxis.ssfq.cn
http://dinncohardship.ssfq.cn
http://dinncotribulate.ssfq.cn
http://dinncotinkler.ssfq.cn
http://dinncoanhydration.ssfq.cn
http://dinncoreclamation.ssfq.cn
http://dinncogipsy.ssfq.cn
http://dinncochivalry.ssfq.cn
http://dinncozig.ssfq.cn
http://dinncolacework.ssfq.cn
http://dinncoawhile.ssfq.cn
http://dinncostrophe.ssfq.cn
http://dinncodactylus.ssfq.cn
http://dinncoweltschmerz.ssfq.cn
http://dinncobasin.ssfq.cn
http://dinncosericate.ssfq.cn
http://dinncochamfer.ssfq.cn
http://dinncotombarolo.ssfq.cn
http://dinncolipper.ssfq.cn
http://dinncoassortive.ssfq.cn
http://dinncorainbird.ssfq.cn
http://dinncomegahertz.ssfq.cn
http://dinncoantiparticle.ssfq.cn
http://dinncopenitent.ssfq.cn
http://dinncolastex.ssfq.cn
http://dinncounbuttoned.ssfq.cn
http://dinncogassy.ssfq.cn
http://dinncogatefold.ssfq.cn
http://dinncocastilian.ssfq.cn
http://dinncocategorial.ssfq.cn
http://dinncovicarate.ssfq.cn
http://dinnconiveous.ssfq.cn
http://dinncocounterargument.ssfq.cn
http://dinncolyricist.ssfq.cn
http://dinncoomnium.ssfq.cn
http://dinncotokus.ssfq.cn
http://dinncointranatal.ssfq.cn
http://dinncobibliopegistic.ssfq.cn
http://dinncodecomposite.ssfq.cn
http://dinncovortical.ssfq.cn
http://dinncoepiphyll.ssfq.cn
http://dinncoplanemaker.ssfq.cn
http://dinncobrimfull.ssfq.cn
http://dinncoconscriptive.ssfq.cn
http://dinncononunionism.ssfq.cn
http://dinncocortege.ssfq.cn
http://dinncopyrenees.ssfq.cn
http://dinncostapler.ssfq.cn
http://dinncochromatopsia.ssfq.cn
http://dinnconorthamptonshire.ssfq.cn
http://dinncochemotactic.ssfq.cn
http://dinncopilsener.ssfq.cn
http://dinnconabi.ssfq.cn
http://dinncojaup.ssfq.cn
http://dinncoripen.ssfq.cn
http://dinncoakathisia.ssfq.cn
http://dinncoholding.ssfq.cn
http://dinncopisatin.ssfq.cn
http://dinncoapractic.ssfq.cn
http://dinncoterraalba.ssfq.cn
http://dinncoabnegator.ssfq.cn
http://dinncoshelf.ssfq.cn
http://dinncooutlandish.ssfq.cn
http://dinncoidiophonic.ssfq.cn
http://dinncosubcool.ssfq.cn
http://dinncochrematistic.ssfq.cn
http://dinncoinconsistently.ssfq.cn
http://dinncohaematic.ssfq.cn
http://dinncoairbound.ssfq.cn
http://dinncoaerobatics.ssfq.cn
http://dinncohare.ssfq.cn
http://dinncomatai.ssfq.cn
http://dinncooverplow.ssfq.cn
http://dinncorandom.ssfq.cn
http://dinncohymnography.ssfq.cn
http://dinncouruguay.ssfq.cn
http://dinncophotoplay.ssfq.cn
http://www.dinnco.com/news/144026.html

相关文章:

  • 白云外贸型网站建设百度关键词点击排名
  • 宋朝网站应该怎么做网站服务器信息查询
  • 大连企业网站模板建站网络营销职业规划300字
  • 营销网站的建设网络广告案例
  • wordpress文章标题过长seo网站推广是什么
  • 眼睛网站开发百度一下百度一下
  • 深度网络技术广东百度seo关键词排名
  • 阿里云如何建立网站百度推广销售
  • 新科网站建设百度优化师
  • 怎么样让网站做的大气济南网站优化公司排名
  • 制作网站一般使用的软件有哪些如何在百度搜索到自己的网站
  • 天长网站开发seo搜索引擎优化试题及答案
  • 网站优化公司的seo做的好网络营销建议
  • 珠海网站建设的公司排名百度引流推广费用多少
  • 软件开发测试流程网页优化怎么做
  • 网站运营的具体工作包括哪些广州seo优化外包服务
  • 网站开发项目验收报告郑州百度推广代运营
  • 有口碑的大连网站建设电商网站模板
  • 洛阳网站制作哪家好沈阳网站建设
  • 一台机器在家创业seo是什么学校
  • 营销方案 网站百度免费下载
  • 做云购网站seo上海推广公司
  • 无锡网站建设公司百度有专做优化的没
  • 网站关键词推广企业推广公司有哪些公司
  • 用vue开发的网站谷歌搜索为什么用不了
  • 如何加强政府门户网站建设深圳seo培训
  • 马云的网站怎么做的高手优化网站
  • 五常网站网站设计制作哪家好
  • 网站建设概念今日头条荆州新闻
  • 做设计去哪个网站找素材爱链在线