亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

搜索
博主信息
博文 48
粉絲 3
評論 1
訪問量 45007
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板
uni-app 自定義導(dǎo)航以及定位
吳長清
原創(chuàng)
2307人瀏覽過
  • 兩個前提:

    • pages.json中取消原生導(dǎo)航

    • manifest.json文件中配置定位服務(wù)

  • 代碼

  1. <template>
  2. <view class="container">
  3. <view class="top" :style="{height:statusBarHeight+'px',width:windowWidth+'px'}"></view>
  4. <view class="box-bg" :style="{height:navbarHeight+'px'}" @click="getLocation">
  5. <image src="/static/dingwei.png"></image>
  6. <text style="color: white;">{{locationName}}</text>
  7. <span style="color: white;" class="iconfont icon-xiala"></span>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. data() {
  14. return {
  15. // 設(shè)置狀態(tài)欄默認(rèn)值高度為20
  16. statusBarHeight: 20,
  17. // 設(shè)置導(dǎo)航欄的默認(rèn)值為45
  18. navbarHeight: 45,
  19. // 設(shè)置手機(jī)寬度默認(rèn)值為375
  20. windowWidth: 375,
  21. // topHeigth:0,
  22. locationName: '請選擇'
  23. }
  24. },
  25. methods: {
  26. getLocation() {
  27. // console.log("點(diǎn)擊事件");
  28. uni.chooseLocation({
  29. // 成功的回調(diào)函數(shù)
  30. success: (res) => {
  31. console.log(res);
  32. // 地理位置字符串大于10時截取前面的字符串即可
  33. res.name.length > 10 ? this.locationName = res.name.substring(0, 9) + '...' : this
  34. .locationName = res.name
  35. },
  36. // 失敗回調(diào)函數(shù)
  37. fail: (res) => {
  38. console.log(res);
  39. }
  40. })
  41. }
  42. },
  43. created() {
  44. // 同步獲取系統(tǒng)(手機(jī))信息
  45. const info = uni.getSystemInfoSync();
  46. // 動態(tài)設(shè)置狀態(tài)欄的高度
  47. this.statusBarHeight = info.statusBarHeight;
  48. // 動態(tài)設(shè)置手機(jī)寬度
  49. this.windowWidth = info.windowWidth;
  50. // 獲取膠囊的位置
  51. const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  52. // console.log(info);
  53. // 動態(tài)設(shè)置導(dǎo)航欄的位置
  54. this.navbarHeight = (menuButtonInfo.bottom - this.statusBarHeight) + (menuButtonInfo.top - this
  55. .statusBarHeight);
  56. }
  57. }
  58. </script>
  59. <style lang="scss">
  60. .top {
  61. background: linear-gradient(100deg, #00d5ff, #00aaff);
  62. }
  63. .box-bg {
  64. background: linear-gradient(100deg, #00d5ff, #00aaff);
  65. padding: 5px 10rpx;
  66. display: flex;
  67. gap: 10rpx;
  68. place-items: center;
  69. image {
  70. width: 50rpx;
  71. height: 50rpx;
  72. background-color: antiquewhite;
  73. border-radius: 510rpx;
  74. }
  75. }
  76. </style>
  • 效果

本博文版權(quán)歸博主所有,轉(zhuǎn)載請注明地址!如有侵權(quán)、違法,請聯(lián)系admin@php.cn舉報處理!
全部評論 文明上網(wǎng)理性發(fā)言,請遵守新聞評論服務(wù)協(xié)議
0條評論
作者最新博文
關(guān)于我們 免責(zé)申明 意見反饋 講師合作 廣告合作 最新更新
php中文網(wǎng):公益在線php培訓(xùn),幫助PHP學(xué)習(xí)者快速成長!
關(guān)注服務(wù)號 技術(shù)交流群
PHP中文網(wǎng)訂閱號
每天精選資源文章推送
PHP中文網(wǎng)APP
隨時隨地碎片化學(xué)習(xí)
PHP中文網(wǎng)抖音號
發(fā)現(xiàn)有趣的

Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號

  • 登錄PHP中文網(wǎng),和優(yōu)秀的人一起學(xué)習(xí)!
    全站2000+教程免費(fèi)學(xué)