美文网首页
权限选择

权限选择

作者: 嗯哼_3395 | 来源:发表于2018-07-07 16:04 被阅读0次
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="vue.js"></script>
    <script src="vue-router.js"></script>
    <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>
</head>
<body>
    <div id="box">
         <router-link to="/">index</router-link>
         <router-link to="/list">list</router-link>
         <button @click="$router.push('/login')">登陆</button>
         <router-view class="view"></router-view>   
    </div>
</body>

    <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>
</html>

相关文章

网友评论

      本文标题:权限选择

      本文链接:https://www.haomeiwen.com/subject/vrtguftx.html