如何在模态中打开vue-router

时间:2017-02-15 15:17:47

标签: vue.js vue-router

我一直试图让路由器视图在模态中工作(比如twitter)。任何人都可以帮忙?

这可能是一种实现目标的方法,但我不确定它是否是正确的方式

const Foo = { template: '<div>foo</div>' }
const Bar = { template: '<div>bar</div>' }

const router = new VueRouter({
  mode: 'history',
  routes: [
    {
      path: '/other',
      components: {
        default: Foo,
        modal: Bar,
      }
    }
  ]
})

new Vue({
	router,
  el: '#app'
})
   
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>

<div id="app">
  <h1>Named Views</h1>
  <ul>
    <li>
      <router-link to="/">/</router-link>
    </li>
    <li>
      <router-link to="/other">/other</router-link>
    </li>
  </ul>
  <router-view class="view one"></router-view>
  <router-view class="view two" name="modal"></router-view>
</div>

如何使用modal router-view在modal中打开?

1 个答案:

答案 0 :(得分:0)

您可以做的是将' first instance may be in the collection If Application.OpenForms.OfType(Of Guidance_Info).Any() Then ...similar issue to below Else ' create a NEW instance (#2) Dim f1 As New Guidance_Info() ' use/create a default instance Guidance_Info.LoadGuidance_Info(strControl) ' show #2 f1.Show() End If 定义为开放式模式。 这样,当您导航到Dim f1 = Application.OpenForms.OfType(Of GuidanceInfo)().FirstOrDefault If f1 IsNot Nothing Then ' use existing f1.LoadInfo(strControl) Else ' create, update, show one new form instance f1 = New GuidanceInfo() f1.LoadInfo(strControl) f1.Show() End If 时,会显示模态,当您离开时,它会被隐藏。