Better-Scroll滚动插件
import BScroll from "better-scroll";<html> <div ref="Content"> <ul ref="Ul"> <li>...</li> </ul> </div></html><script> this.$nextTick(() => { let width = 92; //每个li的宽 this.$refs.Ul.style.width = width * this.seckillGoods.length + 'px'; if (!this.scroll) { this.scroll = new BScroll(this.$refs.Content, { startX: 0, click: true, scrollX: true, // 忽略竖直方向的滚动 scrollY: false, //横向滚动 eventPassthrough: "vertical" }); } else { this.scroll.refresh(); }}); </script>
vuex持久化插件: vuex-persistedstate
import Vuex from 'vuex'import persistedState from 'vuex-persistedstate'new Vuex.store({ moudle: {}, plugins:[persistedState()] //默认使用loacalStorage存 // persistedState({ storage: window.sessionStorage }) //使用sessionStorage存 // persistedState({ //使用cookie存 // storage: { // getItem: key => Cookies.get(key), // setItem: (key, value) => Cookies.set(key, value, { expires: 7 }), // removeItem: key => Cookies.remove(key) // } // })})
localStorage插件:store.js
import * as $ls from 'store'$ls.set('shopNo', '732717077')$ls.get('shopNo')