# elema **Repository Path**: yanyancoming/elema ## Basic Information - **Project Name**: elema - **Description**: Vue.js实战高仿饿了么案例 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-06-09 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # sell > sell app ## Build Setup ``` bash # install dependencies npm install # serve with hot reload at localhost:8080 npm run dev # build for production with minification npm run build # build for production and view the bundle analyzer report npm run build --report ``` For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). ### 1.keep-alive的作用 + 可以缓存数据,当路由切换的时候,避免重复加载,而且保持离开的状态(比如,在购物车选择了一个食物,切换别的页面回来的时候还是会有此食物添加) + vue2.0 keep-alive 不再是一个特殊属性而是一个包裹组件 + keep-alive 不再是一个特殊属性而是一个包裹组件,类似于 比如: ``` ``` + 这样可以在含多种状态子组件中使用 : ``` ``` ### 2.数据存储本地,以及提取的方法 ``` /*数据的存储*/ export function saveToLocal(id,key,val){ var seller = window.localStorage._seller_; if(!seller){ seller = {}; seller[id] = {}; }else{ seller = JSON.parse(seller); if(!seller.id){ seller[id] = {}; } } seller[id][key] = val; localStorage._seller_ = JSON.stringify(seller); } /*数据的读取*/ export function loadFromLocal(id,key,def){ var seller = window.localStorage._seller_; if(!seller){ return def; } seller = JSON.parse(seller); if(!seller[id]){ return def; } return seller[id][key] || def } ``` ### 3.better-scroll的使用条件及方法 ### 4.父子组件相互传值