App.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <script>
  2. export default {
  3. created () {
  4. // 调用API从本地缓存中获取数据
  5. /*
  6. * 平台 api 差异的处理方式: api 方法统一挂载到 mpvue 名称空间, 平台判断通过 mpvuePlatform 特征字符串
  7. * 微信:mpvue === wx, mpvuePlatform === 'wx'
  8. * 头条:mpvue === tt, mpvuePlatform === 'tt'
  9. * 百度:mpvue === swan, mpvuePlatform === 'swan'
  10. * 支付宝(蚂蚁):mpvue === my, mpvuePlatform === 'my'
  11. */
  12. let logs
  13. if (mpvuePlatform === 'my') {
  14. logs = mpvue.getStorageSync({key: 'logs'}).data || []
  15. logs.unshift(Date.now())
  16. mpvue.setStorageSync({
  17. key: 'logs',
  18. data: logs
  19. })
  20. } else {
  21. logs = mpvue.getStorageSync('logs') || []
  22. logs.unshift(Date.now())
  23. mpvue.setStorageSync('logs', logs)
  24. }
  25. },
  26. log () {
  27. console.log(`log at:${Date.now()}`)
  28. }
  29. }
  30. </script>
  31. <style>
  32. .container {
  33. height: 100%;
  34. display: flex;
  35. flex-direction: column;
  36. align-items: center;
  37. justify-content: space-between;
  38. padding: 200rpx 0;
  39. box-sizing: border-box;
  40. }
  41. /* this rule will be remove */
  42. * {
  43. transition: width 2s;
  44. -moz-transition: width 2s;
  45. -webkit-transition: width 2s;
  46. -o-transition: width 2s;
  47. }
  48. </style>