简体   繁体   English

Nuxt.js | 打开一个新页面作为带有路线的模态窗口

[英]Nuxt.js | open a new page as modal window with a route

How can I achieve something like #dribble, #behance, old #twitter overlay?我怎样才能实现像#dribble、#behance、旧的#twitter 覆盖这样的东西? When you open a single project or post there you will see a modal with a route without leaving the page.当您打开单个项目或在那里发布时,您将看到一个带有路线的模式,而无需离开页面。

In simple words modal window with the route.简单来说就是带路由的模态窗口。

For example, when I visit example.com/login or example.com/posts/1 the existing page content should remain and modal should come with a route.例如,当我访问example.com/loginexample.com/posts/1 ,现有的页面内容应该保留,模态应该带有路线。

I hope I made my point clear.我希望我说清楚了。

Thanks谢谢

You can manually change your url like this您可以像这样手动更改您的网址

methods: {
    onOpen() {
        history.pushState({}, 'Login', '/login')
    },

    onClose() {
        history.back()
    }
}

and in your modal component, use onpopstate event handler to close the modal when user hit back button.并在您的模态组件中,使用onpopstate事件处理程序在用户回击按钮时关闭模态。

mounted() {
  window.onpopstate = this.close
},
beforeDestroy() {
  window.onpopstate = null
},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM