Get me outta here!

Friday, March 9, 2018

Click close button remove div section using Vue js

<!DOCTYPE html>
<html>
<head>
    <title>Vue Js</title>
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">

</head>
<style type="text/css">
.panel{
    height: 100%;
    width: 600px;
    padding-top: 50px;
}
.panel-title{
    background-color: gray;
    width: 100%;
    overflow: hidden;
}
.panel-title h2{
    float: left;
    margin-left: 10px;
}
.close{
    float: right;
    margin-right: 10px;
}
.panel-content{
    text-align: justify;
    padding-top: 20px;
}
</style>
<body>
    <center>
        <div id="root">
            <panel title="This is test">
                <h1>Enter Username:- </h1>
                <input type="text" name="" placeholder="Enter name...">
                <input type="button" name="" value="submit">
            </panel>
        </div>
    </center>


    <!--js plugin-->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
    <script>
        Vue.component("panel", {
            template:` <div class="panel" v-if="show">
            <div class="panel-title">
            <h2>{{ title }}</h2>
            <button class="close" @click="show=false">x</button>
            </div>
            <div class="panel-content">
            <slot></slot>
            </div>
            </div> `,
            props:["title","content"],
            data:function(){
                return{
                    show:true
                }
            }
        });
        var app = new Vue({
            el:"#root",
            data:{

            }

        });
    </script>
</body>
</html>

0 comments:

Post a Comment