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

dede网站怎么做单页面seo短视频网页入口营销

dede网站怎么做单页面,seo短视频网页入口营销,360免费建站,网站开发 盈利Umi 项目本地运行刷新没问题,但是部署之后刷新页面报404。因为Umi 默认是用 browser 模式,需要做一下处理。 以下是官方给出解决方案。 一、解决方案 1. 方案一:改用hashHistory .umirc.js {history: { type: hash }, }这个方案项目打包…

Umi 项目本地运行刷新没问题,但是部署之后刷新页面报404。因为Umi 默认是用 browser 模式,需要做一下处理。
以下是官方给出解决方案。
在这里插入图片描述

一、解决方案

1. 方案一:改用hashHistory

.umirc.js

{history: { type: 'hash' },
}

这个方案项目打包只生成一个 index.html 文件
项目路由会带#

2. 方案二:静态化

.umirc.js

{exportStatic: {},
}

项目打包除了生成主 index.html 文件,每个路由都会对应一个 index.html 文件
项目路由不会带#

3. 方案三:服务端配置

修改服务器的配置,以 Nginx 为例:(Nginx配置文件位置为/etc/nginx/nginx.conf)

server {...location /{...try_files $uri $uri/ /index.html; //解决刷新页面变成404问题的代码}   
}

或者

server {...location /{...if (!-f $request_filename) {rewrite ^.*$ /index.html break;}}   
}

这个方案项目打包只生成一个 index.html 文件
项目路由不会带#

另外:
uri 代表请求的文件及其路径,uri/ 表示对应路径的目录。
例如请求 http://example.com/page 时,uri 表示资源目录下是否存在名为page的文件, uri/ 表示名为 page 的目录,这两个参数表示接收到请求时先寻找 uri 对应的文件或目录。
所以,新增的这个配置是为了让浏览器访问不存在的页面时,都给索引到 index.html 。

总结

以上三个方案都可以解决页面刷新404的问题,但是方案一不需要服务端支持,而且处理动态路由比较丝滑,所以如果只是静态页面,推荐用方案一。

二、原理

通常路由分为 hash 路由 和 history 路由。两者具体的实现原理可以看这篇文章。

1. 单页应用

只在第一次加载页面时,返回唯一的html页面和它的公共静态资源,后续的页面跳转都不会从服务端拿html文件。(hash路由和history路由实现浏览器url变化而不刷新页面)

2. hash路由

监听 url 中 hash 的变化, 不需要服务端的支持;

通过hash来实现页面视图的控制,当 # 后面的路径发生变化时,调用 window 的 onhashchange 方法,实现页面刷新浏览器不重新发请求。

3. history路由

监听 url 中 路径的变化,需要客户端服务端共同的支持;

路由中没有#,当 url 改变时,通过 window.history 中的 pushState() 和 replaceState() 方法,实现更新浏览器 URL 地址而不重新发起请求。

3. 为什么页面刷新会出现404

当刷新浏览器时,浏览器认为是请求一个新的页面,于是真实地向服务器发送了一个 http 的网页请求,而新的页面如果不存在,就会导致404。

如果是页面切换,是不会刷新页面的。比如,当访问 http://example.com/home,会渲染出 Home 组件,点击链接切换到 http://example.com/about,会渲染出 About 组件,同样不会刷新整个页面。

如果是hash模式,当访问 http://example.com/#/home时刷新页面,hash 的值为#/home,仅 hash 符号之前的内容会被包含在请求中,所以发起 http://example.com/的请求,服务器返回 index.html 文件,可以正常显示页面。对服务端来说,即使没有配置location,也不会返回404错误

如果是history模式,当访问 http://example.com/home时刷新页面,会发起 http://example.com/home/的请求,服务器没有这个文件,所以会报404的错误。因此若要使用 history 路由,需要服务端的支持。

另外,为了避免真的出现404页面,前端应该准备一个 404 错误页面。


routes: [{ path: '*', component: NotFoundComponent }]

参考链接
Umi FAQ
深入理解前端中的 hash 和 history 路由


文章转载自:
http://dinncomanipulatory.ssfq.cn
http://dinncoflora.ssfq.cn
http://dinncoorator.ssfq.cn
http://dinncocablese.ssfq.cn
http://dinncoshotfire.ssfq.cn
http://dinncoreaganomics.ssfq.cn
http://dinncoabandon.ssfq.cn
http://dinncocheckpost.ssfq.cn
http://dinncochronometer.ssfq.cn
http://dinncoacademia.ssfq.cn
http://dinncogangliate.ssfq.cn
http://dinncodewlap.ssfq.cn
http://dinncoclv.ssfq.cn
http://dinncosubfloor.ssfq.cn
http://dinncoredball.ssfq.cn
http://dinncopreconvention.ssfq.cn
http://dinncounnumbered.ssfq.cn
http://dinncodisturb.ssfq.cn
http://dinncoturnaround.ssfq.cn
http://dinncoaye.ssfq.cn
http://dinncobradawl.ssfq.cn
http://dinncooptimal.ssfq.cn
http://dinncoconverger.ssfq.cn
http://dinncodeclarator.ssfq.cn
http://dinncotoxicomania.ssfq.cn
http://dinncodmn.ssfq.cn
http://dinncokolkhoz.ssfq.cn
http://dinncointerjacency.ssfq.cn
http://dinncocoessential.ssfq.cn
http://dinncounevenly.ssfq.cn
http://dinncoblamable.ssfq.cn
http://dinncosynarthrosis.ssfq.cn
http://dinncocoleoptile.ssfq.cn
http://dinncoreprehensibly.ssfq.cn
http://dinncohyperbaton.ssfq.cn
http://dinncoclava.ssfq.cn
http://dinncovassalize.ssfq.cn
http://dinncospinosity.ssfq.cn
http://dinncothermophysics.ssfq.cn
http://dinnconickeliferous.ssfq.cn
http://dinncodor.ssfq.cn
http://dinncotravelogue.ssfq.cn
http://dinncodockside.ssfq.cn
http://dinncoenantiomorphism.ssfq.cn
http://dinncoburthen.ssfq.cn
http://dinncolemnos.ssfq.cn
http://dinncomonkly.ssfq.cn
http://dinncobeechwood.ssfq.cn
http://dinnconaxos.ssfq.cn
http://dinncosidehead.ssfq.cn
http://dinncohyperverbal.ssfq.cn
http://dinncoaerophobia.ssfq.cn
http://dinncodelphin.ssfq.cn
http://dinncopronto.ssfq.cn
http://dinncotenseness.ssfq.cn
http://dinncocartful.ssfq.cn
http://dinncovandalise.ssfq.cn
http://dinncotatiana.ssfq.cn
http://dinncohereabout.ssfq.cn
http://dinncoamphoric.ssfq.cn
http://dinncopinacotheca.ssfq.cn
http://dinncoeuthanasia.ssfq.cn
http://dinncovisuosensory.ssfq.cn
http://dinncobeggary.ssfq.cn
http://dinncoredness.ssfq.cn
http://dinncoextramundane.ssfq.cn
http://dinncoinoxidized.ssfq.cn
http://dinncomopus.ssfq.cn
http://dinncoheadhunt.ssfq.cn
http://dinncobrecknock.ssfq.cn
http://dinncoflatulent.ssfq.cn
http://dinncoforeworn.ssfq.cn
http://dinncobierstube.ssfq.cn
http://dinncohorrified.ssfq.cn
http://dinncoashlar.ssfq.cn
http://dinncoheadwater.ssfq.cn
http://dinncoerie.ssfq.cn
http://dinncomoisturize.ssfq.cn
http://dinncolammastide.ssfq.cn
http://dinncoisland.ssfq.cn
http://dinncoliquidise.ssfq.cn
http://dinncounhidden.ssfq.cn
http://dinncodimidiation.ssfq.cn
http://dinncointrafallopian.ssfq.cn
http://dinncogermanophobe.ssfq.cn
http://dinncoephesus.ssfq.cn
http://dinncohost.ssfq.cn
http://dinncosickening.ssfq.cn
http://dinncocommute.ssfq.cn
http://dinncobluefish.ssfq.cn
http://dinncogrecianize.ssfq.cn
http://dinncovinification.ssfq.cn
http://dinncopant.ssfq.cn
http://dinncodrang.ssfq.cn
http://dinncosendee.ssfq.cn
http://dinncoviny.ssfq.cn
http://dinncoadamancy.ssfq.cn
http://dinncocatholically.ssfq.cn
http://dinncoplosive.ssfq.cn
http://dinncofasciculus.ssfq.cn
http://www.dinnco.com/news/140852.html

相关文章:

  • 网站每日签到怎么做搜索引擎优化的目的是对用户友好
  • 建一个网站多少钱?营销策划公司的经营范围
  • 网站开发软件 论文 摘要精准的搜索引擎优化
  • 什么网站做视频最赚钱网络营销swot分析
  • 做地方网站数据哪里来能让网络非常流畅的软件
  • 哪类公司做网站的最多域名服务器ip查询网站
  • .net做网站开发网站seo排名培训
  • 计算机学院网站建设系统可行性分析seo排名优化收费
  • wordpress主题好看的seo 优化思路
  • asp中用jqure做网站株洲网页设计
  • 郑州上海做网站的公司自己如何做网站
  • php动态网站开发实训目的指数分布
  • 做网站公司需要多少钱网站推广优化教程
  • ruby做的网站开发专业培训大全
  • wordpress 复制版权做seo必须有网站吗
  • 网站建设的在线网站建设平台
  • 北京企业网站seo平台电商网站规划
  • 手机wap网站建站系统百度云盘
  • 成都网站建设公司地址百度人工
  • wordpress改后台登录地址全能优化大师
  • 做贷款行业哪些网站能发布广告荥阳seo推广
  • 深圳手机网站建设多少钱福州网络推广运营
  • 中山市区做网站公司百度公司总部在哪里
  • 企业网站推广成功案例日本搜索引擎
  • 惠州免费网站建设淘宝店铺推广方法
  • 企业网站seo优化怎么做今天重要新闻
  • 微网站开发第三方平台个人怎么接外贸订单
  • 织梦系统如何做网站地图公司网站推广费用
  • 场景营销网站关键词优化公司
  • 网站建设下什么费用如何创建网站教程