Vueå°é²
æ¼ç¤ºææ1
å° data ä¸çæ°æ®æ¸²æå°é¡µé¢ä¸ã
é¢è§ https://huanghe1993.github.io/chapter01/02Vue-demo2.html
<img src='http://man.hhaxmm.cn/blog/20190513/e4PC2JAFK38y.png' align='left' />
示ä¾ä»£ç 1ï¼
<div id="app">
{{message}}
<hr />
{{msg2}}
<hr />
{{msg}}
<hr />
{{arr}}
<hr />
{{json}}
</div>
<script src="./lib/vue-2.4.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!',
msg2:10,
msg:true,
arr:['apple','banner','orange'],
json:{a:'å¼ ä¸',b:'æå',c:'çäº'}
}
});
</script>
æ¼ç¤ºææ2
å®ç°æ°æ®ååç»å®ã
é¢è§ https://huanghe1993.github.io/chapter01/02Vue-demo3.html
<img src='http://man.hhaxmm.cn/blog/20190513/VSg65MogAxJR.gif' align='left' />
示ä¾ä»£ç 2ï¼
<!--
* @Description:
* @Author: river
* @Date: 2019-05-13 15:32:13
* @LastEditTime: 2019-05-13 15:35:57
* @LastEditors: huanghe
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
#demo {
width: 800px;
margin: 200px auto;
}
input {
width: 600px;
height: 50px;
border: 10px solid green;
padding-left: 10px;
font: 30px/50px "微软é
é»";
}
.msg {
width: 600px;
font: 30px/50px "微软é
é»";
color: red;
}
</style>
<script src="./lib/vue-2.4.0.js" type="text/javascript" charset="utf-8"></script>
<script>
window.onload = function () {
new Vue({
el: '#demo',
data: {
msg: 'welcome vue.js',
}
})
}
</script>
</head>
<body>
<div id="demo">
<input v-model='msg'>
<div class="msg">
{{msg}}
</div>
</div>
</body>
</html>
å°messageç»å®å°ææ¬æ¡ï¼å½æ´æ¹ææ¬æ¡çå¼æ¶ï¼<p>{{ message }}</p>
ä¸çå
容ä¹ä¼è¢«æ´æ°ã
ä¸é¢ç¨å°çv-model
æ¯Vue.js常ç¨çä¸ä¸ªæ令ï¼é£ä¹æ令æ¯ä»ä¹å¢ï¼
Vue.jsçæ令æ¯ä»¥v-å¼å¤´çï¼å®ä»¬ä½ç¨äºHTMLå ç´ ï¼æ令æä¾äºä¸äºç¹æ®çç¹æ§ï¼å°æ令ç»å®å¨å ç´ ä¸æ¶ï¼æ令ä¼ä¸ºç»å®çç®æ å ç´ æ·»å ä¸äºç¹æ®çè¡ä¸ºï¼æ们å¯ä»¥å°æ令çä½ç¹æ®çHTMLç¹æ§ï¼attributeï¼ã
Vue.jså ·æè¯å¥½çæ©å±æ§ï¼æ们ä¹å¯ä»¥å¼åä¸äºèªå®ä¹çæ令ï¼åé¢çæç« ä¼ä»ç»èªå®ä¹æ令ã
æ¼ç¤ºææ3
渲æjsonæ°æ®ã
é¢è§ï¼https://huanghe1993.github.io/chapter01/02Vue-demo4.html
<img src='http://man.hhaxmm.cn/blog/20190513/4JavRjzR0YVb.png' align='left' />
代ç 示ä¾3
<!--
* @Description:
* @Author: river
* @Date: 2019-05-13 15:52:17
* @LastEditTime: 2019-05-13 15:52:37
* @LastEditors: huanghe
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app">
<ol>
<li v-for="list in msg">
{{list.name}}
{{list.age}}
{{list.addr}}
</li>
</ol>
</div>
<script src="vue.js"></script>
<script type="text/javascript">
new Vue({
el: '#app', //
data: {
msg: [{
name: 'å¼ ä¸1',
age: '18',
addr: 'vue1'
},
{
name: 'å¼ ä¸2',
age: '18',
addr: 'vue2'
},
{
name: 'å¼ ä¸3',
age: '18',
addr: 'vue3'
},
{
name: 'å¼ ä¸4',
age: '18',
addr: 'vue4'
},
{
name: 'å¼ ä¸5',
age: '18',
addr: 'vue5'
},
{
name: 'å¼ ä¸6',
age: '18',
addr: 'vue6'
}
]
}
});
</script>
</body>
</html>
上一篇: Vue的学习之路十三:品牌列表案例实战