# wheretogo
**Repository Path**: NightEmperor/wheretogo
## Basic Information
- **Project Name**: wheretogo
- **Description**: No description available
- **Primary Language**: JavaScript
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2018-05-24
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Vue去哪儿网App
## keep-alive 组件
keep-alive 组件的作用是,从内存中来取得网页,但是有些网页访问时不能从内存中取:
city组件切换到主页时,城市方式变化,主页内容的数据也应该发生变化
主页访问详情页时,不同列表对应的详情页不同
有两种方法可以解决:
第一种:
使用activated和deactivated声明周期函数,keep-alive 组件激活时这两个周期函数才有效
调用activated函数来发送ajax请求,刷新页面
第二种:
给keep-alive添加exclude属性,如exclude="Detail",这时候Detail组件不受keep-alive的影响
当然也没有activated和deactivated
## main.js入口文件
### swiper
`import VueAwesomeSwiper from 'vue-awesome-swiper'`引入swiper
`import 'swiper/dist/css/swiper.css'`引入swiper样式
`Vue.use(VueAwesomeSwiper);`全局挂载
## Vue实例
```
new Vue({
el: '#app',
router,
store,
components: { App },
template: ''
});
```
APP下的每个组件都可以通过`this.$store`访问store
router的作用: 因为APP组件的内容有 router-view标签,表示路径不同,显示对应的组件 ,
APP下的每个组件都可以通过`this.$router.push('/')`进行页面跳转