1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <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>
|