Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Vue Alert Component</title>
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
  
  <bt-alert type="success" title="Important">My Message here.</bt-alert>
  <template id="vue-alert">
    <div v-if="show" class="alert alert-{{type}} alert-dismissible" role="alert">
      <button @click="removeAlert" type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span>
      </button>
      <strong>{{title}}!</strong> {{message}}
    </div>
  </template>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.js"></script>
</body>
</html>
 
Vue.component('bt-alert', {
  template: '#vue-alert',
  props: ['type', 'title', 'message'],
  data: function() {
    return {
      show: true
    };
  },
  created: function() {
    console.log(this.$children);
    this.message = this.innerHTML;
  },
  methods: {
    removeAlert: function() {
      this.show = false;
    }
  }
});
var vm = new Vue({
  el: 'body'
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers