App.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div id="app">
  3. <keep-alive v-if="$route.meta.keepAlive">
  4. <router-view v-wechat-title="$route.meta.title" />
  5. </keep-alive>
  6. <router-view v-else v-wechat-title="$route.meta.title" />
  7. <div class="vc-tigger" @click="toggleVc"></div>
  8. </div>
  9. </template>
  10. <script>
  11. import { env } from '@/config'
  12. export default {
  13. name: 'App',
  14. data() {
  15. return {
  16. lastClickTime: 0,
  17. count: 0,
  18. limit: env === 'production' ? 10 : 0
  19. }
  20. },
  21. created() {
  22. console.log(this.$wx)
  23. },
  24. methods: {
  25. handleTouchMove(event) {
  26. event.preventDefault()
  27. },
  28. hasClass(obj, cls) {
  29. return obj.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'))
  30. },
  31. addClass(obj, cls) {
  32. if (!this.hasClass(obj, cls)) obj.className += ' ' + cls
  33. },
  34. toggleClass(obj, cls) {
  35. if (this.hasClass(obj, cls)) {
  36. this.removeClass(obj, cls)
  37. } else {
  38. this.addClass(obj, cls)
  39. }
  40. },
  41. removeClass(obj, cls) {
  42. if (this.hasClass(obj, cls)) {
  43. var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)')
  44. obj.className = obj.className.replace(reg, ' ')
  45. }
  46. },
  47. toggleVc() {
  48. // const nowTime = new Date().getTime()
  49. // if (nowTime - this.lastClickTime < 3000) {
  50. // this.count++
  51. // } else {
  52. // this.count = 0
  53. // }
  54. // this.lastClickTime = nowTime
  55. // if (this.count >= this.limit) {
  56. // const vconDom = document.getElementById('__vconsole')
  57. // this.toggleClass(vconDom, 'show')
  58. // this.count = 0
  59. // }
  60. const vconDom = document.getElementById('__vconsole')
  61. this.toggleClass(vconDom, 'show')
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="scss">
  67. .vc-tigger {
  68. position: absolute;
  69. top: 0;
  70. right: 0;
  71. width: 5px;
  72. height: 5px;
  73. // background: red;
  74. }
  75. .show {
  76. display: block !important;
  77. }
  78. </style>