用于与Vue的本地存储交互的Reactive层

  • G2_960930
    了解作者
  • 9.7KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-05 10:34
    上传日期
用于与Vue的本地存储交互的Reactive层。Vue 2插件
用于与Vue的本地存储交互的Reactive层.zip
  • ropbla9-vue-reactive-storage-4f73e32
  • src
  • make-storage.js
    324B
  • make-mixin.js
    492B
  • index.js
    261B
  • test
  • src
  • main.js
    243B
  • App.vue
    1.3KB
  • index.html
    198B
  • webpack.config.js
    1.8KB
  • .babelrc
    84B
  • README.md
    319B
  • .gitignore
    59B
  • package.json
    764B
  • dist
  • index.js
    4.6KB
  • .eslintrc.js
    109B
  • webpack.config.js
    424B
  • README.md
    1.1KB
  • .gitignore
    14B
  • package.json
    1.1KB
内容介绍
# vue-reactive-storage Reactive layer for interacting with localStorage from Vue. Plugin for Vue 2. ### why `window.localStorage` cannot be reactive if you use it directly with Vue, ex ```js new Vue({ data { localStorage: window.localStorage }, template: " <div> {{localStorage.notes}}, {{localStorage.lang}} ... </div> ", created: function() { this.localStorage.lang = "other value"; } }) ``` Code above will not react, even bind to view. So... ### how to use ```js import reactiveStorage from "vue-reactive-storage"; Vue.use(reactiveStorage, { "notes": String, "lang": String, "name": String, "count": Number,    "userConfig": Object }); ``` Define vars that will be stored and proxied by `Vue` (any other var in `window.localStorage` that is not on this array will not be proxied). Now you can acess the namespace <code>localStorage</code> in Vue. ```js new Vue({ template: " <div> {{localStorage.notes}}, {{localStorage.lang}} ... </div> ", created: function() { this.localStorage.lang = "other value"; // will react on the view and on real localStorage. } }) ```
评论
    相关推荐