App.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <div id="app">
  3. <router-view />
  4. <div class="userAgentTips" v-if="userAgentTipShow">
  5. <img src="./assets/userAgentWarning.png" width="32px" />
  6. <span>当前浏览器可能与网站不兼容!建议使用 chrome 浏览器获得最佳使用体验。 </span>
  7. <img src="./assets/userAgentClose.png" width="16px" @click="handleClickUserAgent" />
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. export default {
  13. name: "App",
  14. data() {
  15. return {
  16. userAgentTipShow: false,
  17. };
  18. },
  19. created() {
  20. this.handleUserAgentRoot()
  21. },
  22. methods:{
  23. // 判断是否为chrome浏览器
  24. handleUserAgentRoot(){
  25. if(!sessionStorage.getItem("useragent_root_close") && navigator.userAgent.indexOf('Chrome') == -1){
  26. this.userAgentTipShow = true
  27. }
  28. },
  29. handleClickUserAgent(){
  30. sessionStorage.setItem("useragent_root_close", true);
  31. this.userAgentTipShow = false
  32. },
  33. }
  34. };
  35. </script>
  36. <style lang="scss" scoped>
  37. .userAgentTips{
  38. position: fixed;
  39. top: 62px;
  40. left: 50%;
  41. // width: 624px;
  42. margin-left: -312px;
  43. background: #FFFFFF;
  44. border-radius: 8px;
  45. padding: 12px 16px 12px 8px;
  46. display: flex;
  47. align-items: center;
  48. justify-content: space-between;
  49. font-size: 16px;
  50. line-height: 24px;
  51. :nth-child(1){
  52. margin-right: 8px;
  53. }
  54. :nth-child(3){
  55. cursor: pointer;
  56. }
  57. }
  58. </style>