V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
edis0n0
V2EX  ›  程序员

不借助路由组件有办法实现在跳转同站别的页面时播放的音频不中断吗?

  •  
  •   edis0n0 · 2023-01-16 13:53:08 +08:00 · 1076 次点击
    这是一个创建于 458 天前的主题,其中的信息可能已经有所发展或是发生改变。
    7 条回复    2023-01-17 08:57:41 +08:00
    99s
        1
    99s  
       2023-01-16 13:57:12 +08:00
    iframe 呀,我记得网易云音乐就是这么搞的
    godall
        2
    godall  
       2023-01-16 14:18:25 +08:00
    都 3000 年了,这个问题还解决不了?
    1. 古老方式:iframe
    2.现代方式:ajax 异步加载网页内容。
    sparkle2015
        3
    sparkle2015  
       2023-01-16 14:35:21 +08:00
    一种解决方案:Turbolinks 。相关的 blog: https://baurine.com/2018/10/02/uninterrupted-audio-player-turbolinks/ - 借助 Turbolinks 实现不间断的网页音乐播放器
    shenyuzhi
        4
    shenyuzhi  
       2023-01-16 15:56:25 +08:00
    另外一种思路:把音频播放器的页面完全独立出来,页面之间通过 sessionStorage 或者借助后端 api 通信。
    mmmfj
        5
    mmmfj  
       2023-01-16 17:23:41 +08:00
    连 iframe 都不需要,只要把 audio 标签放到最顶层,路由组件之外
    bojackhorseman
        6
    bojackhorseman  
       2023-01-16 17:25:51 +08:00
    @mmmfj #5 vue3 的 teleport 组件是不是就可以用来做这个
    296727
        7
    296727  
       2023-01-17 08:57:41 +08:00
    这个时候忘记微前端了?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5293 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 07:42 · PVG 15:42 · LAX 00:42 · JFK 03:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.