Hide html elements in vuejs2 -
i want hide html elements during initial load, clicking button or link show html elements. can't find solution hide or show element in vuejs2 version. can able see few options in vuejs not sure how use methods. below component code in want hide html element(id) "message".
<template> <div class="row"> <div class="col-lg-12"> <label class="checkbox checkbox-inline no_indent"> <input type="checkbox" value="">show stats </label> </div> </div> <div class="row"> <div class="col-lg-12"> <div class="panel-group"> <div class="panel panel-primary"> <div class="panel-heading"> <h3 class="panel-title">list values</h3> </div> <div class="panel-body"> <button type="button" id="btn1" class="btn btn-warning btn-md" v-on:click="showworkflow">test 1</button> <button type="button" id="btn2" class="btn btn-danger btn-md" v-on:click="showworkflow">test 2</button> <button type="button" id="btn3" class="btn btn-info btn-md" v-on:click="showworkflow">test 3</button> </div> </div> </div> </div> </div> <div class="row"> <div id="message">hello here</div> </div> </template> <script> export default { name: 'jobs', methods: { showworkflow: function (e) { console.log(e.target.id) } } } </script>
make showworkflow
data property set false
.
use argument v-if
directive on content want hide.
then, when want show content, set showworkflow
true
:
new vue({ el: '#app', data() { return { showworkflow: false, } }, })
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.2/vue.min.js"></script> <div id="app"> <div v-if="showworkflow"> here workflow </div> <button @click="showworkflow = true">show workflow</button> </div>
Comments
Post a Comment