vue.js component
2016-05-28 本文已影响327人
ZhouJiping
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue js</title>
</head>
<body>
<div id="app">
<counter heading="Likes" color="green"></counter>
<counter heading="DisLikes" color="red"></counter>
</div>
<template id="counter-templete">
<h1>{{ heading }}</h1>
<button @click="count += 1" style="background: {{ color }}">{{count}}</button>
</template>
<script src="vue.js"></script>
<script>
Vue.component('counter', {
template:'#counter-templete',
props:['heading', 'color'],
data : function () {
return { count : 0};
}
});
new Vue({
el: "#app"
});
</script>
</body>
</html>