home.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="home">
  3. 首页
  4. <view class="box"></view>
  5. <icon type="success" size="26" />
  6. <icon type="clear" size="26" />
  7. <icon type="search" size="26" />
  8. <h1 class="h1">你好</h1>
  9. <text space='emsp'>今 三</text>
  10. <h2>你好</h2>
  11. <text space="nbsp">今 三</text>
  12. <h2>你好</h2>
  13. <text space="ensp">今 三</text>
  14. <button @click="getList">获取列表信息</button>
  15. <button @click="getMain">新增</button>
  16. <button @click="showMain">获取</button>
  17. <button @click="upImage">上传图片</button>
  18. <view v-for="item in list">
  19. <view>{{item}}</view>
  20. <!-- <image :src="item"></image> -->
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import {
  26. getMsgList
  27. } from '../../api/home.js'
  28. export default {
  29. data() {
  30. return {
  31. list:[]
  32. }
  33. },
  34. methods: {
  35. getList() {
  36. getMsgList().then(res => {
  37. console.log(res, 'res ')
  38. })
  39. },
  40. getMain() {
  41. // new Promise((resolve,reject)=>{
  42. // })
  43. // const aa = Promise.resolve()
  44. // aa.then(()=>{
  45. // console.log(2)
  46. // })
  47. // console.log(1)
  48. uni.setStorageSync('storage_key1', 'hello1')
  49. uni.setStorage({
  50. key: 'storage_key2',
  51. data: 'hello2',
  52. });
  53. },
  54. showMain() {
  55. console.log(uni.getStorageSync('storage_key1'), '异步')
  56. console.log(uni.getStorage({
  57. key: 'storage_key2',
  58. success: function(res) {
  59. console.log(res.data);
  60. }
  61. }), '同步')
  62. },
  63. upImage() {
  64. uni.chooseImage({
  65. count: 6,
  66. success: function (res) {
  67. console.log(res);
  68. this.list = res.tempFilePaths;
  69. console.log(this.list,'aaa')
  70. }
  71. });
  72. }
  73. }
  74. }
  75. </script>
  76. <style scoped lang="scss">
  77. @import url("../../test.css");
  78. text {
  79. color: $uni-color-primary;
  80. }
  81. .box {
  82. width: 300rpx;
  83. height: 300rpx;
  84. background: #00f;
  85. }
  86. </style>