<html>
<body>
<div id="app">
<input v-model="input">
<my-component :texta="12"></my-component>
</div>
</body>
<script>
Vue.component('my-component',{
props:['texta'],
template:'<div>{{text}}</div>',
data:function(){
console.log('data函数')
let a = 1
return {
text:parseInt(this.texta)
}
}
})
const app = new Vue({
el:'#app',
data:{
input:'',
a:1
}
})
</script>
</html>
.red{
color:red;
}
.green{
color:green;
}