12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <template>
- <view class="content">
- <button type="primary" @click="saveData">存储数据</button>
- <button type="primary" @click="getData">获取数据</button>
- <view style="margin-top: 50rpx">
- <hello></hello>
- <some-one v-if="showSomeHide"></some-one>
- </view>
- <button type="primary" @click="hideSome" style="margin-top: 50rpx">影藏someone</button>
- </view>
- </template>
- <script>
- import hello from '../../components/hello/hello.vue';
- import SomeOne from '../../components/someOne/someOne.vue';
- export default {
- components: { hello, SomeOne },
-
-
-
- data() {
- return {
- showSomeHide:true
- };
- },
-
- 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);
- },
- });
- },
- hideSome(){
- this.showSomeHide = !this.showSomeHide
- },
- },
- };
- </script>
- <style>
- .content {
- margin: 20rpx;
- }
- </style>
|