2017-02-15 17 views
1

私はモーダル(ツイッターのような)でルータービューの作業をしようとしていました。誰でも助けることができますか?モーダルでvue-routerを開く方法

これは多分それをachiveするための方法ですが、私はそれが正しい方法モーダルの内側にオープンするモーダルルータ・ビューを使用する方法

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({ 
 
\t 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>

であるかどうかわからないんだけど?

答えて

0

あなたができることは、開いたモーダルとしてBarを定義することです。 このようにしてotherに移動すると、モーダルが表示され、移動すると非表示になります。

関連する問題