Khandaker Toihidul Islam
Software Engineer
Backend : PHP | Mysql | Symfony | CakePhp | Wordpress | Drupal
Frontend : Node js | Vue js | React Js | Javascript | HTML | CSS | Bootstrap
Tools , Server : Nginx | Apache | Git | Jenkins | Jira | Asana | Silenium | Spira

Stor data in vue component


<div id="app" class="text-center">
  <my-component></my-component>
  <my-component></my-component>
</div>

<div id="app2" class="text-center">
  <my-component></my-component>
</div>
<script type="text/javascript">
	// register
	Vue.component('my-component', {
		data: function(){
			return{
				status: 'Critical'
			}
		},
		template : "<p> Server Status: {{ status }} <button @click='changeStatus'>Click</button> </p>",
		methods: {
			changeStatus: function(){
				this.status = 'Normal';
			}
		}
	});

	new Vue({
	  el: '#app'
	})

	new Vue({
	  el: '#app2'
	})
</script>

Demo http://vue.toihid.com/section-7/storing-data-in-component.php

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *