0
点赞
收藏
分享

微信扫一扫

七、Vue生命周期函数之mounted()------页面刷新时调用

​mounted()​​​方法和​​data()​​​和​​methods​​是同级别的

<script>
export default {
name: 'app',
data() {
return {
todo: '',
list: []
}
},
methods: {

},
// 生命周期函数 页面刷新时调用
mounted() {
//取出缓存 因为存入的时候用JSON序列化了,所以取要反序列化
var list = JSON.parse(localStorage.getItem('list'));
if (list) {
this.list = list;
}
}
}
</script>


举报

相关推荐

0 条评论