<template>
  <view class="content">
    <button type="primary" @click="saveData">存储数据</button>
    <button type="primary" @click="getData">获取数据</button>
    <view>
      <hello></hello>
    </view>
  </view>
</template>

<script>
import hello from '../../components/hello/hello.vue';



export default {
  components: { hello },
 
  
  
  data() {
    return {};
  },
  
  methods: {
    saveData() {
      uni.setStorage({
        key: "user",
        data: {
          id: 3241354,
          name: "asdfasf",
          age: 18,
          sex: "男",
        },
        success() {
          console.log("success");
        },
        fail(err) {
          console.log(err);
        },
      });
    },
    getData() {
      uni.getStorage({
        key: "user",
        success(res) {
          console.log(res);
        },
        fail(err) {
          console.log(err);
        },
      });
    },
  },
};
</script>

<style>
.content {
  margin: 20rpx;
}
</style>
