element-request-fullscreen-bugs.uvue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <view>
  3. <view style="padding: 8px;">
  4. <view class="position-error" id="fullscreen" @click="requestfullscreen">
  5. <text style="color: white;">测试position:fixed在安卓上的bug</text>
  6. </view>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. fullscreenElement: null as UniElement | null,
  15. isFullscreen: false,
  16. }
  17. },
  18. onReady() {
  19. this.fullscreenElement = uni.getElementById('fullscreen') as UniElement
  20. },
  21. methods: {
  22. getCurrentPage() : UniPage {
  23. const pages = getCurrentPages()
  24. return pages[pages.length - 1]
  25. },
  26. requestfullscreen() {
  27. if (this.isFullscreen) {
  28. const page = this.getCurrentPage()
  29. page.exitFullscreen({
  30. success: () => {
  31. },
  32. fail: () => {
  33. },
  34. complete: () => {
  35. }
  36. })
  37. } else {
  38. this.fullscreenElement?.requestFullscreen({
  39. success: () => { },
  40. fail: () => { },
  41. complete: () => { }
  42. })
  43. }
  44. this.isFullscreen = !this.isFullscreen
  45. },
  46. exitfullscreen() {
  47. }
  48. }
  49. }
  50. </script>
  51. <style>
  52. .position-error {
  53. width: 200px;
  54. height: 200px;
  55. position: fixed;
  56. background-color: brown;
  57. }
  58. </style>