vue第äºå¤©ç¬è®°01ââç»ä»¶ç两ç§å®ä¹æ¹å¼
程序员文章站
2022-03-29 18:43:12
...
ä¸ã第ä¸ç§å®ä¹
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<!-- 书åå ä½ç¬¦,å çè¿ä¸ªä½ç½®ï¼ä»¥åä¼è¢«ç»ä»¶æ¿æ¢ã
å ä½ç¬¦çååä¸è½åæ ç¾ååä¸æ ·-->
<v-header></v-header>
</div>
<script src="../js/vue.js"></script>
<script>
//ç»ä»¶ç±»ä¼¼äºä¸ä¸ªå°ç页é¢ï¼éé¢å
æ¬htmlï¼cssï¼js
/*å®ä¹ä¸»ä»¶:
var ç»ä»¶å={
template : '页é¢ç»æ',
data(){
return{
åéå : åéå¼
}
},
methods : {
æ¹æ³å:function(){
å
·ä½æ¹æ³
}
}
}
*/
var header = {
// template:书å页é¢ç»æï¼éé¢åªè½åå¨ä¸ä¸ªæ ¹æ ç¾
template : '<div><p v-on:click="change()">æå{{msg}}</p><h5>æ é¢</h5></div>',
data(){
return{
msg : 0
}
},
methods : {
change:function(){
this.msg++;
}
}
//template : '<p>æå</p><h5>æ é¢</h5>'//æ¥é,åªè½åå¨ä¸ä¸ªæ ¹æ ç¾
}
new Vue({
el : '#app',
/* æè½½ç»ä»¶ : {
'å ä½ç¬¦' : ç»ä»¶å
}
*/
components : {
'v-header' : header
}
})
</script>
</body>
</html>
äºã第äºç§å®ä¹
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<!-- å ä½ç¬¦ -->
<v-header></v-header>
</div>
<!-- template(模æ¿:书å页é¢ç»æ)å¿
é¡»ç¬ç«å,ä¸è½åå¨appå
é¨ -->
<template id="header">
<!-- åæ ·åªè½åå¨ä¸ä¸ªæ ¹æ ç¾ -->
<div>
<p v-on:click="change()">æå{{msg}}</p>
<h5>æ é¢</h5>
</div>
</template>
<script src="../js/vue.js"></script>
<script>
/* å®ä¹ç»ä»¶:
var ç»ä»¶å = {
template : '模æ¿çid',
data(){
return{
åéå : åéå¼
}
},
methods : {
æ¹æ³å : function(){
å
·ä½æ¹æ³
}
}
}
*/
var header = {
template : '#header',
data(){
return{
msg : 0
}
},
methods : {
change : function(){
this.msg++;
}
}
}
new Vue({
el : '#app',
/* æè½½ç»ä»¶ : {
'å ä½ç¬¦' : ç»ä»¶å
}
*/
components : {
'v-header' : header
}
})
</script>
</body>
</html>
ç»ä»¶çå®ä¹ï¼
1.书åå ä½ç¬¦
2.å®ä¹ç»ä»¶ç页é¢ç»æãæ°æ®åæ¹æ³ç
3.æè½½ç»ä»¶