<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="js/vue.js"></script>
</head>
<body>
<div id="app">
<runoob></runoob>
</div>
<script>
var Child = Vue.extend({
template:`<h1>自定义组件!{{address}}
<p>{{name}}</p></h1>
`,
data(){
return{
address:'北极',
name:'gcg'
}
}
})
new Vue({
el: '#app',
components: {
'runoob': Child
}
})
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="js/vue.js"></script>
</head>
<body>
<div id="app">
<runoob></runoob>
<p>{{msg}}</p>
</div>
<script>
var Child = Vue.extend({
template:`<h1>自定义组件!{{address}}
<p>{{name}}</p></h1>
`,
data(){
return{
address:'北极',
name:'gcg'
}
}
})
new Vue({
el: '#app',
data(){
return{
msg:'fff'
}
},
components: {
'runoob': Child
}
})
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="js/vue.js"></script>
<style>
.mybutton{
width: 300px;
}
</style>
</head>
<body>
<div id="app">
<runoob></runoob>
<p>{{msg}}</p>
<people></people>
</div>
<script>
var adult = Vue.extend({
template:`<h1>自定义组件!{{address}}
<p>{{name}}</p></h1>
`,
data(){
return{
address:'北极',
name:'gcg'
}
}
})
const people=Vue.extend({
template:`
<div>
<input type="text" v-model="telphone">
<p>{{telphone}}</p>
<button type="button" @click="showtelephone" :class="mybutton" ></button>
</div>
`,
data(){
return{
telphone:'17302275258',
mybutton:'mybutton'
}
},
methods:{
showtelephone(){
alert(this.telphone);
}
}
})
new Vue({
el: '#app',
data(){
return{
msg:'fff'
}
},
components: {
'runoob': adult,
people
}
})
</script>
</body>
</html>