vue中操作localstorage

首先在子组件将localstorage方法进行封装

在父组件中对其进行引用

将输入的值存入到定义的searchHistory数组中,存储localstorage需要传两个参数,变量名为searchHistory,值为searchHistory的数组,调用封装好的setStore方法

将存储到localstorage的值,取出来

做的是一个搜索,将localstorage显示出来了

posted @ 2019-07-30 12:06  甄利伟  阅读(3418)  评论(0编辑  收藏  举报