UNPKG

vuejs-local-storage

Version:

Vue plugin for work with LocalStorage from Vue context

35 lines (30 loc) 615 B
import ls from './localStorage'; let VueLocalStorage = { /** * Install plugin * * @param {Object} Vue * @param {Object} options * @returns {Storage} */ install (Vue, options) { ls.options = Object.assign(ls.options, { namespace: '' }, options || {}); Vue.ls = ls; Object.defineProperty(Vue.prototype, '$ls', { /** * Define $ls property * * @return {Storage} */ get () { return ls; } }); } }; if (typeof window !== 'undefined') { window.VueLocalStorage = VueLocalStorage; } export default VueLocalStorage;