[TOC]
-----
## vue嘗鮮
### 演示效果1
將 data 中的數據渲染到頁面上。
>[success] 預覽:https://ityanxi.github.io/Vue-tutorial/chapter01/02vue-demo1.html

>[success]示例代碼1
~~~
<div id="app">
{{message}}
<hr />
{{msg2}}
<hr />
{{msg}}
<hr />
{{arr}}
<hr />
{{json}}
</div>
<script src="vue.js"></script>
<script type="text/javascript">
new Vue({
el:'#app',//
data:{
message:'Hello Vue!',
msg2:10,
msg:true,
arr:['apple','banana','orange','pear'],
json:{a:'張三',b:'李四',c:'王五'}
}
});
</script>
~~~
-----
### 演示效果2
實現數據雙向綁定。
>[success]預覽:https://ityanxi.github.io/Vue-tutorial/chapter01/02vue-demo2.html

>[success]示例代碼2
~~~
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#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="vue.js"></script>
<script type="text/javascript">
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>
~~~
----
### 演示效果3
渲染json數據。
>[success]預覽:https://ityanxi.github.io/Vue-tutorial/chapter01/02vue-demo3.html

>[success]代碼示例3
~~~
<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>
~~~
--------
### 演示效果4
渲染圖書電商數據,數據存儲在libary.json中,https://ityanxi.github.io/Vue-tutorial/chapter01/libary.json
>[success]預覽:https://ityanxi.github.io/Vue-tutorial/chapter01/02vue-demo4.html

>[success]代碼示例4
~~~
<div id="app">
<h1>圖書電商數據</h1>
<table>
<thead>
<tr>
<th>ID</th>
<th>分類</th>
</tr>
</thead>
<tbody>
<tr v-for="list in result">
<td>{{list.id}}</td>
<td>{{list.catalog}}</td>
</tr>
</tbody>
</table>
</div>
<script src="vue.js"></script>
<script type="text/javascript">
new Vue({
el:'#app',//
data:{
"resultcode":"200",
"reason":"success",
"result":[
{
"id":"242",
"catalog":"中國文學"
},
{
"id":"252",
"catalog":"人物傳記"
},
{
"id":"244",
"catalog":"兒童文學"
},
{
"id":"248",
"catalog":"歷史"
},
{
"id":"257",
"catalog":"哲學"
},
{
"id":"243",
"catalog":"外國文學"
},
{
"id":"247",
"catalog":"小說"
},
{
"id":"251",
"catalog":"心靈雞湯"
},
{
"id":"253",
"catalog":"心理學"
},
{
"id":"250",
"catalog":"成功勵志"
},
{
"id":"249",
"catalog":"教育"
},
{
"id":"245",
"catalog":"散文"
},
{
"id":"256",
"catalog":"理財"
},
{
"id":"254",
"catalog":"管理"
},
{
"id":"246",
"catalog":"經典名著"
},
{
"id":"255",
"catalog":"經濟"
},
{
"id":"258",
"catalog":"計算機"
}
],
"error_code":0
}
});
</script>
~~~
--------
### 演示效果5
渲染微信精選數據,數據存儲在wechat.json中,https://ityanxi.github.io/Vue-tutorial/chapter01/wechat.json
>[success]預覽:https://ityanxi.github.io/Vue-tutorial/chapter01/02vue-demo5.html

>[success]代碼示例5
~~~
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
h1{
text-align: center;
}
table,
td,
th {
border-collapse: collapse;
border-spacing: 0
}
table {
/*width: 400px;*/
margin: 0 auto;
text-align: center;
}
td,
th {
border: 1px solid #bcbcbc;
padding: 5px 10px;
}
th {
background: #42b983;
font-size: 1.2rem;
font-weight: 400;
color: #fff;
cursor: pointer;
}
tr:nth-of-type(odd) {
background: #fff;
}
tr:nth-of-type(even) {
background: #eee;
}
a{
text-decoration: none;
display: block;
padding: 5px 10px;
background: #269ABC;
color:#fff;
}
</style>
</head>
<body>
<div id="app">
<h1>微信精選文章</h1>
<table>
<thead>
<tr>
<th>ID</th>
<th>標題</th>
<th>來源</th>
<th>圖片</th>
<th>查看</th>
</tr>
</thead>
<tbody>
<tr v-for="list in result['list']">
<td>{{list.id}}</td>
<td>{{list.title}}</td>
<td>{{list.source}}</td>
<td><img :src="list.firstImg" alt="" width="300"/></td>
<td><a :href="list.url" target="_blank">閱讀原文</a></td>
</tr>
</tbody>
</table>
</div>
<script src="vue.js"></script>
<script type="text/javascript">
new Vue({
el:'#app',//
data:{
"reason":"請求成功",
"result":{
"list":[
{
"id":"wechat_20170524020647",
"title":"這才是中國說話禮儀,太全了!",
"source":"騰訊網",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-25166268.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524020647"
},
{
"id":"wechat_20170524021107",
"title":"十八層地獄都是什么樣子?勸世人多行善",
"source":"刀墓手札",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-25166891.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524021107"
},
{
"id":"wechat_20170524022075",
"title":"編輯部殺人事件",
"source":"故事會",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-25167481.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524022075"
},
{
"id":"wechat_20170524020087",
"title":"生活的美好,緣于一顆平常心",
"source":"情緒管理",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-24770365.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524020087"
},
{
"id":"wechat_20170524020085",
"title":"做一個純粹的女人",
"source":"情緒管理",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-15035340.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524020085"
},
{
"id":"wechat_20170524020223",
"title":"看懂的請給下一個人",
"source":"環球好聽英文歌",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-15866850.static\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524020223"
},
{
"id":"wechat_20170524020612",
"title":"你知道嗎?好茶是泡出來的,好人是做出來的!",
"source":"普洱茶界",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-25166255.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524020612"
},
{
"id":"wechat_20170524020995",
"title":"子若強于我,要錢做什么?子若不如我,留錢做什么(說得太好了!)",
"source":"洲際電池圈",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-21531071.static\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524020995"
},
{
"id":"wechat_20170524022415",
"title":"電纜人必看!借錢見人心,還錢見人品!",
"source":"買賣寶",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-25167687.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524022415"
},
{
"id":"wechat_20170523061558",
"title":"孩子出不出色,取決于媽媽的性格(深度好文)",
"source":"媽媽手冊",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-24679658.static\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170523061558"
},
{
"id":"wechat_20170524017876",
"title":"每日詩詞(359-109)",
"source":"詩詞月刊",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-25164852.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524017876"
},
{
"id":"wechat_20170524002636",
"title":"新婚不久丈夫去世,漂亮的妻子第二天就...太現實了!",
"source":"每日幽默小視頻",
"firstImg":"",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524002636"
},
{
"id":"wechat_20170524014500",
"title":"【我與濃情黑土地文學平臺之緣】韓治林:我與濃情黑土地平臺",
"source":"濃情黑土地",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-18100317.static\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524014500"
},
{
"id":"wechat_20170524014630",
"title":"書畫|精美五百羅漢圖 五百羅漢的由來 附500羅漢全名單",
"source":"上上閣藝術沙龍",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-25163758.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524014630"
},
{
"id":"wechat_20170524014621",
"title":"【漲知識】特稿寫作秘訣在這里,拿走不謝!",
"source":"中國報業",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-25163761.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524014621"
},
{
"id":"wechat_20170524014617",
"title":"書畫|美國 Ricky.Mujica 瑞奇.穆希卡超現實浪漫主義繪畫欣賞",
"source":"上上閣藝術沙龍",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-25163726.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524014617"
},
{
"id":"wechat_20170524014603",
"title":"視聽|心經的境界 佛音《般若波羅密多心經》-演唱:王蓉",
"source":"上上閣藝術沙龍",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-25163713.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524014603"
},
{
"id":"wechat_20170524014607",
"title":"文化|中國古代四大美女之二《落雁?回望昭君》朗誦:高昂",
"source":"上上閣藝術沙龍",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-25163715.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524014607"
},
{
"id":"wechat_20170524015424",
"title":"宗譜在我心中-記駱相生宗叔(修正版)",
"source":"駱姓論壇",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-25164030.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524015424"
},
{
"id":"wechat_20170524015418",
"title":"安徽蕪湖繁陽駱氏《忠懇堂》建祠修譜公告",
"source":"駱姓論壇",
"firstImg":"http:\/\/zxpic.gtimg.com\/infonew\/0\/wechat_pics_-25164010.jpg\/640",
"mark":"",
"url":"http:\/\/v.juhe.cn\/weixin\/redirect?wid=wechat_20170524015418"
}
],
"totalPage":3739,
"ps":20,
"pno":1
},
"error_code":0
}
});
</script>
</body>
</html>
~~~
- 前端新手村
- 前言
- 第1章 遇見Vue.js
- 第一個Vue.js程序
- vue嘗鮮
- 第2章 概念理解
- 漸進式框架
- 虛擬DOM
- MVVM模式
- MVX模式是什么
- 第3章 Vue基礎概覽
- 第4章 Vue內置指令詳解
- vue-text
- vue-html
- v-show
- v-if
- v-else
- v-else-if
- v-for
- v-on
- v-bind
- v-model
- v-pre
- v-cloak
- v-once
- 第5章 基礎demo小練習
- 圖書管理系統
- 頁面布局
- 列表渲染
- 功能實現
- 基于BootStrap+Vuejs實現用戶信息表
- 功能描述
- 布局實現
- 星座判斷
- 第6章 組件
- 什么是組件
- 使用組件
- Prop
- 自定義事件
- 使用Slot分發內容
- 動態組件
- 雜項
- 第7章-過渡
- 過渡效果
- 概述
- 單元素/組件的過渡
- 初始渲染的過渡
- 多個元素的過渡
- 多個組件的過渡
- 列表過渡
- 可復用的過渡
- 動態過渡
- 過渡狀態
- 狀態動畫與watcher
- 動態狀態轉換
- 通過組件組織過渡
- Render函數
- 基礎
- createElement參數
- 使用JavaScript代替模板功能
- JSX
- 函數化組件
- 模板編譯
- 自定義指令
- 簡介
- 鉤子函數
- 鉤子函數參數
- 函數簡寫
- 對象字面量
- Vuex狀態管理
- Vuex是什么?
- Vuex的安裝
- Vuex起步
- data的替代品-State和Getter
- 測試Getter
- Action-操作的執行者
- 測試Action
- 只用Mutation修改狀態
- 測試Mutations
- Vuex的基本結構
- 子狀態和模塊
- 用服務分離外部操作
- Vue-router
- Vue-router是什么
- Vue-router安裝
- 基本用法1
- 基本用法2
- Vue-cli
- Vue中的Node.js
- Vue中的npm、cnpm
- Vue中的webpack
- 安裝
- 基本使用
- 模板
- 全局API
- Vue.extend
- Vue.nextTick
- Vue.set
- Vue.delete
- Vue.directive
- Vue.filter
- Vue.component
- Vue.use
- Vue.mixin
- Vue.compile
- 附錄
- 相關網站
- 尤雨溪
- 第10章 webpack
- webpack安裝
- webpack基本使用
- webpack命令行
- webpack配置文件
- 單頁面應用SPA
- 第1章 Vue.js簡介
- 1.1 Vue.js簡介
- 1.1.1 Vue.js是什么
- 1.1.2 為什么要用Vue.js
- 1.1.3 Vue.js的發展歷史
- 1.1.4 Vue.js與其他框架的區別
- 1.2 如何使用Vue.js
- 1.2.1 第一個Vue.js程序
- 1.2.2 Vue.js小嘗鮮
- 1.3 概念詳解
- 1.3.1 什么是漸進式框架
- 1.3.2 虛擬DOM是什么
- 1.3.3 如何理解MVVM
- 第2章 基礎概覽
- 2.1 Vue實例
- 2.1.1 構造器
- 2.1.2 屬性與方法
- 2.1.3 實例生命周期
- 2.1.4 生命周期圖示
- 2.2 模板語法
- 2.2.1 插值
- 2.2.2 指令
- 2.2.3 過濾器
- 2.2.4 縮寫
- 第3章 Class與Style的綁定
- 第4章 模板渲染
- 第5章 事件詳解
- 第6章 表單控件綁定
- 第7章 指令詳解
- 7.1 內部指令
- 7.2 自定義指令
- 7.3 指令的高級選項
- 第8章 計算屬性
- 第9章 過濾器
- 第10章 組件
- 10.1 什么是組件
- 10.2 注冊組件
- 10.3 組件選項
- 10.4 組件間的通信
- 10.5 內容分發
- 10.6 動態組件