npm install vue-rescroll --save
複製代碼
import VueRescroll from 'vue-rescroll';
Vue.use(VueRescroll);
複製代碼
import { directive } from 'vue-rescroll';
directives: {
'rescroll': directive
}
複製代碼
<div v-rescroll="{name: 'A unique marker'}"></div>
複製代碼
key | require | value | type | discribe |
---|---|---|---|---|
name | 是 | string | 用來保存滾動狀態的key值 | |
type | 否 | 'default'/'window' | string | 滾動類型(局部,全局) |
storageMode | 否 | 'default'/'localstorage' | string | 滾動狀態保存方式 |
domType | 否 | 'default'/'tab' | string | 是否爲tab切換組件 |
<div v-rescroll="{ name: `${id}-scroll`, type: 'window', storageMode: 'localstorage' }" ></div>
複製代碼
頁面不要使用keep-alive緩存,那樣的話,鉤子函數不會觸發。
Don't use keep-alive caching for your pages. In that case, the hook function won't trigger
javascript
使用vuex緩存數據/use vuexhtml
async created () {
if (hasData) return hasData;
return await this.getData();
}
複製代碼
必需要每次刷新的頁面/must refreshedvue
async created () {
openLoading();
await this.getData();
closeLoading();
}
複製代碼
github地址,以爲有用,歡迎start,歡迎一塊兒討論。
詳細描述各類現象博客地址java