black11black
V2EX  ›  问与答

前端的 href 之类的属性,配置前端路由后会导致递归引用吗?

  •  
  •   black11black · Mar 11, 2020 · 1015 views
    This topic created in 2266 days ago, the information mentioned may be changed or developed.

    今天想到的一个问题,比如 vue 中 css 是用类似这种方式引用的

    <link href=/static/css/app.css rel=preload as=style>
    

    配置前端路由后,404 由前端路由处理,比如一个基础设置是,nginx 匹配到 404 就重定向到 index.html。

    那么假如我某一天手滑,在 index.html 的<link>标签的 href 里加入了不存在的地址,那么他会被重定向至 index.html,这种情况下浏览器解析是将其当做纯文本,还是同样会当做 html 页面解释并执行?(后者的话不就意味着递归调用 index.html 然后导致崩溃?)

    谢谢

    1 replies    2020-03-11 20:50:19 +08:00
    noe132
        1
    noe132  
       Mar 11, 2020   ❤️ 1
    明显你声明的是 style,就会被当成 style 解析。
    html 不是合法的 style。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5320 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 09:02 · PVG 17:02 · LAX 02:02 · JFK 05:02
    ♥ Do have faith in what you're doing.