権限の選択

2110 ワード




    
    
    <script src="vue.js"/>
    <script src="vue-router.js"/>
    <style>
       *{
           margin:0;
           padding:0;
       }
       #box{
          margin:0 auto;
          width: 200px;
          margin-top: 20px;
       }
       .view{
           width: 200px;
           height: 300px;
           margin-top: 20px;
           border: 1px solid red;
       }
    </style>


    <div id="box">
         <router-link to="/">index</router-link>
         <router-link to="/list">list</router-link>
         <button> </button>
         <router-view class="view"/>   
    </div>


    <script>
var index={
    template:`<h1> </h1>`
}
var list={
    template:`<h1> </h1>`
}
var login={
    data:function(){
        return{
            name:""
        }
    },
    template:`<div><input type="text" v-model="name"><button @click="add"> </button></div>`,
    methods:{
        add:function(e){
            sessionStorage.setItem("name",this.name);
            var name=sessionStorage.getItem("name");
        }
    }
}

router=new VueRouter({
      routes:[
             {
                path:"/",
                component:index
             },
             {
                path:"/list",
                component:list,
                meta:{
                    check:true
                }
             },{
                path:"/login",
                component:login
             }
      ]
 })


       var box=new Vue({
          el:"#box",
          data:{
              flag:false
          },
          router:router
       })

router.beforeEach(function(to,from,next){
    if(to.fullpath!="/login")
    
}
</script>

</code></pre> 
</article>
                            </div>
                        </div>