6:options(選項):javascript
7:實例:html
事件前端
8:全局vue
9: 組件傳值java
父傳子: 屬性做爲參數webpack
子傳父: vuebus(只能是同一輛車)ios
組件內的過濾器 + 全局過濾器git
組件內過濾器就是options中的一個filters的屬性(一個對象)github
全局過濾器- `Vue.filter(名,fn)` 組件內的過濾器 - `filters:{test(option){ return option.split()}}`
總結web
在獲取的地方加入 this.$refs.名稱A
若是ref放在了原生DOM元素上,獲取的數據就是原生DOM對象
若是ref放在了組件對象上,獲取的就是組件對象
對應的事件
注意:
若是是所有安裝的方式
vue的核心插件:
使用方式
npm i vue-router -S
import VueRouter from 'vue-router';
Vue.use(VueRouter);
4:建立路由對象並配置路由規則
let router = new VueRouter({ routes:[ {path:'/home',component:Home} ] });
5:將其路由對象傳遞給Vue的實例,options中
router:router
<router-view></router-view>
使用router-link標籤
<router-link to="/beijing">去北京</router-link>
2:去哪裏 <router-link :to="{name:'bj'}">去北京</router-link>
查詢字符串
<router-link :to="{name:'detail',query:{id:1} } ">xxx</router-link>
{ name:'detail' , path:'/detail',組件}
3:去了幹嗎,獲取路由參數(要注意是query仍是params和對應id名)
this.$route.query.id
path方式
<router-link :to="{name:'detail',params:{name:1} } ">xxx</router-link>
{ name:'detail' , path:'/detail/:name',組件}
3:去了幹嗎,獲取路由參數(要注意是query仍是params和對應name名)
this.$route.params.name
this.$router.push(直接跳轉到某個頁面顯示)
{name:'xxx',query:{id:1},params:{name:2} }
在代碼中經過this.$refs.xxx 獲取其元素
聲明週期事件(鉤子)回調函數
路由
window.addEventListener('hashchange',fn);
<router-view></router-view><div id="xxx"></div>
做爲一個DOM上的標識{ path:'/' ,redirect:'/home' }
{ path:'/' ,redirect:{name:'home'} }
404 : 在路由規則的最後的一個規則
{ path:'*' , component:notFoundVue}
之前能夠一次放一個坑對應一個路由和顯示一個組件
components 多視圖 是一個對象 對象內多個key和value
<router-view></router-view>
-> name就是default<router-view name='xxx'></router-view>
-> name就是xxxrouter-view所在頁面:
<router-view></router-view> //對應xx頁面 <router-view name="footer"></router-view>//對應xxx頁面 <router-view name="header></router-view>//對應xxxx頁面
router/index.js頁面:
components:{default:xx,footer:xxx,header:xxxx}
期組件內包含着第一層router-view { name:'music' ,path:'/music', component:Music , children:[ 子路由的path /就是絕對路徑 不/就是相對父級路徑 {name:'music.oumei' ,path:'oumei', component:Oumei }, {name:'music.guochan' ,path:'guochan', component:Guochan } ] }
1:路由核心
2:http請求