定 價:¥69.00
作 者: | (英)卡勒姆·麥克雷 |
出版社: | 電子工業(yè)出版社 |
叢編項: | |
標 簽: | 暫缺 |
ISBN: | 9787121352997 | 出版時間: | 2018-11-01 | 包裝: | 平裝 |
開本: | 16開 | 頁數(shù): | 196 | 字數(shù): |
前言 .............................................................................................xi
第 1 章 Vue.js 基礎(chǔ) .......................................................................1
為什么選擇 Vue.js ..................................................................................................1
安裝和設(shè)置 ............................................................................................................4
vue-loader 和 webpack .....................................................................................4
模板(Template)、數(shù)據(jù)(Data)和指令(Directive)...........................................6
v-if vs v-show .......................................................................................................10
模板中的循環(huán) ......................................................................................................11
屬性綁定 ..............................................................................................................13
響應式 ..................................................................................................................15
響應式如何實現(xiàn) ............................................................................................16
注意事項 .......................................................................................................17
雙向數(shù)據(jù)綁定 ......................................................................................................19
動態(tài)設(shè)置 HTML ..................................................................................................21
方法 .....................................................................................................................22
this.................................................................................................................23
計算屬性 ..............................................................................................................24
偵聽器 ..................................................................................................................27
監(jiān)聽 data 對象中某個對象的屬性 .................................................................29
獲取舊值 .......................................................................................................29
深度監(jiān)聽 .......................................................................................................30
過濾器 ..................................................................................................................30
使用 ref 直接訪問元素 .........................................................................................33
輸入和事件 ..........................................................................................................33
v-on 簡寫 .......................................................................................................34
事件修飾符 ...................................................................................................34
生命周期鉤子 ......................................................................................................37
自定義指令 ..........................................................................................................38
鉤子函數(shù)參數(shù) ................................................................................................40
過渡和動畫 ..........................................................................................................41
CSS 過渡 .......................................................................................................41
JavaScript 動畫 ..............................................................................................44
總結(jié) .....................................................................................................................46
第 2 章 Vue.js 組件 .....................................................................47
組件基礎(chǔ) ..............................................................................................................47
數(shù)據(jù)、方法和計算屬性 ........................................................................................48
傳遞數(shù)據(jù) ..............................................................................................................49
Prop 驗證 .......................................................................................................50
Prop 的大小寫 ...............................................................................................51
響應式 ...........................................................................................................52
數(shù)據(jù)流和 .sync 修飾符 ..................................................................................53
自定義輸入組件與 v-model ...........................................................................56
使用插槽(slot)將內(nèi)容傳遞給組件 ...................................................................57
默認內(nèi)容 .......................................................................................................58
具名插槽 .......................................................................................................59
作用域插槽 ...................................................................................................60
自定義事件 ..........................................................................................................62
混入 .....................................................................................................................65
混入對象和組件的合并 .................................................................................67
vue-loader 和 .vue 文件 ........................................................................................68
非 Prop 屬性 ........................................................................................................70
組件和 v-for 指令 ................................................................................................71
總結(jié) .....................................................................................................................74
第 3 章 使用 Vue 添加樣式 ..........................................................77
Class 綁定 ............................................................................................................77
內(nèi)聯(lián)樣式綁定 ......................................................................................................79
數(shù)組語法 .......................................................................................................80
多重值 ...........................................................................................................80
用 vue-loader 實現(xiàn) Scoped CSS ...........................................................................81
用 vue-loader 實現(xiàn) CSS Modules .........................................................................82
預處理器 ..............................................................................................................83
總結(jié) .....................................................................................................................83
第 4 章 render 函數(shù)和 JSX ..........................................................85
標簽名稱 ..............................................................................................................86
數(shù)據(jù)對象 ..............................................................................................................86
子節(jié)點 ..................................................................................................................88
JSX ......................................................................................................................89
總結(jié) .....................................................................................................................91
第 5 章 使用 vue-router 實現(xiàn)客戶端路由 ......................................93
安裝 .....................................................................................................................93
基本用法 ..............................................................................................................94
HTML5 History 模式 ...........................................................................................96
動態(tài)路由 ..............................................................................................................97
響應路由變化 ................................................................................................98
路由參數(shù)作為組件屬性傳入 .......................................................................100
嵌套路由 ............................................................................................................101
重定向和別名 ....................................................................................................103
鏈接導航 ............................................................................................................104
tag 屬性 .......................................................................................................105
active-class 屬性 ..........................................................................................106
原生事件 .....................................................................................................107
編程式導航 .................................................................................................107
導航守衛(wèi) ............................................................................................................108
路由獨享守衛(wèi) ..............................................................................................110
組件內(nèi)部守衛(wèi) .............................................................................................. 111
路由順序 ............................................................................................................112
404 頁面 ......................................................................................................113
路由命名 ............................................................................................................114
總結(jié) ...................................................................................................................115
第 6 章 使用 vuex 實現(xiàn)狀態(tài)管理 ................................................117
安裝 ...................................................................................................................118
概念 ...................................................................................................................119
State 及其輔助函數(shù) ............................................................................................121
State 輔助函數(shù).............................................................................................122
Getter .................................................................................................................124
Getter 輔助函數(shù) ...........................................................................................126
Mutation .............................................................................................................126
Mutation 輔助函數(shù) ......................................................................................128
Mutation 必須是同步函數(shù) ...........................................................................128
Action ................................................................................................................129
Action 輔助函數(shù) ..........................................................................................130
參數(shù)解構(gòu) .....................................................................................................131
Promise 與 Action ..............................................................................................131
Module ...............................................................................................................132
文件結(jié)構(gòu) .....................................................................................................134
帶命名空間的模塊 ......................................................................................135
總結(jié) ...................................................................................................................137
第 7 章 對 Vue 組件進行測試 .....................................................139
測試單個組件 ....................................................................................................139
介紹 vue-test-utils ..............................................................................................141
查詢 DOM ..........................................................................................................142
掛載選項 ............................................................................................................143
模擬和存根數(shù)據(jù) .................................................................................................145
測試事件 ............................................................................................................146
總結(jié) ...................................................................................................................148
附錄 A 搭建 Vue 開發(fā)環(huán)境 .........................................................149
附錄 B Vue 與 React ................................................................153
索引 ..........................................................................................171