当前位置:   article > 正文

vue3项目中使用百度地图和高德地图,添加控件,搜索api, 热力图_/api-j/jindu/hotreport

/api-j/jindu/hotreport

 分享: 因为百度地图和高德地图没有对应封装好的组件适合vue3项目,如果读者是vue2项目就很好写了,vue-baidu-map官方文档 vue-Amap  分别是百度和高德地图 的vue2封装好的组件非常全,如果说我们有功能没有实现,可以在百度、高德的官方api平台进行学习!有收获的话,点赞收藏不迷路~ 蟹蟹

作者:web端项目,vue3 

1.百度地图

  1. <!-- 百度地图的入口文件 -->
  2.   <script type="text/javascript"
  3.     src="https://api.map.baidu.com/api?v=1.0&type=webgl&您自己的密钥"></script>
  4.   <script type="text/javascript"
  5.     src="//api.map.baidu.com/api?type=webgl&v=1.0&&您自己的密钥"></script>
  6.   <script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&&您自己的密钥"></script>
  7.  百度地图热力图引入
  8.   <script type="text/javascript" src="//api.map.baidu.com/library/Heatmap/2.0/src/Heatmap_min.js"></script>
  1. 代码如下:vue3项目中可以直接复制体验一下,记得引入入口文件,申请百度的密钥
  2. <template>
  3.   <div class="border">
  4.     <!-- v-if="echartHidden" -->
  5.     <div id="container" style="height: 80vh; width: 100%"></div>
  6.     <div id="search">
  7.       <a-input
  8.         v-model:value="searchValue"
  9.         @keyup.enter="theLocation"
  10.         id="tipinput"
  11.         placeholder="请输入要搜索的位置"
  12.         style="width: 200px; margin: -3px 0 0 12px"
  13.       />
  14.       <!-- <input
  15.         type="text"
  16.         style="width: 200px; margin: 12px 0 0 12px"
  17.         @keyup.enter="theLocation"
  18.         id="tipinput"
  19.         placeholder="请输入要搜索的位置"
  20.       /> -->
  21.       <div id="searchResultPanel" style="border: 1px solid #c0c0c0; width: 150px; height: auto; display: none"></div>
  22.       <a-button type="primary" @click="theLocation">
  23.         <template #icon><SearchOutlined /></template>
  24.       </a-button>
  25.     </div>
  26.   </div>
  27. </template>
  28. <script setup>
  29. import http from 'utils/request'
  30. import { SearchOutlined, DownOutlined, CloseOutlined } from '@ant-design/icons-vue'
  31. import { ref, onMounted, watch, onUnmounted } from 'vue'
  32. const url = {
  33.   hotreport: '/api-j/jindu/hotreport'
  34. }
  35. const searchValue = ref('')
  36. const lnglat = ref('')
  37. var heatmapOverlays = ref('')
  38. const echartHidden = ref(false)
  39. var map = ''
  40. var mapData = ''
  41. // 获取热力图api
  42. const getHeatmap = async () => {
  43.   const heatmapOverlay = new BMapLib.HeatmapOverlay({
  44.     radius: 24
  45.   })
  46.   console.log(map, '--->map')
  47.   console.log(heatmapOverlay, '--->heatmapOverlay')
  48.   map.addOverlay(heatmapOverlay)
  49.   heatmapOverlay.setDataSet({ data: mapData, max: 100 })
  50.   heatmapOverlay.show()
  51.   // alert(window.getComputedStyle(box, null).height)
  52. }
  53. const mapList = async () => {
  54.   // 把接口数据做一个修改
  55.   const res = await http.get(url.hotreport, { params: {} })
  56.   mapData = [...res.data]
  57.   mapData.map(item => {
  58.     item.count = item.value //这里的count为目标属性名
  59.     delete item.value
  60.   })
  61. }
  62. mapList()
  63. console.log(mapData)
  64. const getMapList = async () => {
  65.   BMap = window.BMap
  66.   BMapGL = window.BMapGL
  67.   console.log(BMap)
  68.   console.log(BMapGL)
  69.   map = new BMap.Map('container') // 创建地图实例
  70.   var size = new BMap.Size(10, 20)
  71.   var point = new BMap.Point(116.4, 39.9) // 创建点坐标
  72.   map.centerAndZoom(point, 12)
  73.   map.enableScrollWheelZoom(true) //开启鼠标滚轮缩放
  74.   var opts = { offset: new BMap.Size(1534, 13) } // 添加比例尺控件
  75.   map.addControl(new BMap.ScaleControl(opts))
  76.   map.addControl(new BMap.MapTypeControl()) //地图的显示类型:包括地图和卫星
  77.   // 测试控件
  78.   map.addControl(new BMap.NavigationControl()) // 添加缩放控件
  79.   map.addControl(new BMap.CityListControl({ showPanel: true })) // 添加城市列表控件
  80.   // 下面是搜索功能标注加精确定位
  81.   let marker = new BMap.Marker(point)
  82.   map.addOverlay(marker)
  83.   var ac = new BMap.Autocomplete({
  84.     //建立一个自动完成的对象
  85.     input: 'tipinput',
  86.     location: map
  87.   })
  88.   ac.addEventListener('onhighlight', function (e) {
  89.     console.log(e)
  90.     //鼠标放在下拉列表上的事件
  91.     var str = ''
  92.     var _value = e.fromitem.value
  93.     console.log(e.fromitem.value)
  94.     var value = ''
  95.     if (e.fromitem.index > -1) {
  96.       value = _value.province + _value.city + _value.district + _value.street + _value.business
  97.     }
  98.     str = 'FromItem<br />index = ' + e.fromitem.index + '<br />value = ' + value
  99.     value = ''
  100.     if (e.toitem.index > -1) {
  101.       _value = e.toitem.value
  102.       value = _value.province + _value.city + _value.district + _value.street + _value.business
  103.     }
  104.     str += '<br />ToItem<br />index = ' + e.toitem.index + '<br />value = ' + value
  105.     G('searchResultPanel').innerHTML = str
  106.   })
  107.   var myValue
  108.   ac.addEventListener('onconfirm', function (e) {
  109.     //鼠标点击下拉列表后的事件
  110.     var _value = e.item.value
  111.     console.log(e.item.value)
  112.     myValue = _value.province + _value.city + _value.district + _value.street + _value.business
  113.     G('searchResultPanel').innerHTML = 'onconfirm<br />index = ' + e.item.index + '<br />myValue = ' + myValue
  114.     map.centerAndZoom(myValue, 11)
  115.     setPlace()
  116.   })
  117.   function setPlace() {
  118.     map.clearOverlays() //清除地图上所有覆盖物
  119.     function myFun() {
  120.       var pp = local.getResults().getPoi(0).point //获取第一个智能搜索的结果
  121.       map.centerAndZoom(pp, 18)
  122.       map.addOverlay(new BMap.Marker(pp)) //添加标注
  123.     }
  124.     var local = new BMap.LocalSearch(map, {
  125.       //智能搜索
  126.       onSearchComplete: myFun
  127.     })
  128.     local.search(myValue)
  129.   }
  130. }
  131. onMounted(() => {
  132.   getMapList()
  133.   //一定要先让地图加载出来才加载热力图,我这里做演示直接写个setTimeout了
  134.   setTimeout(() => {
  135.     getHeatmap()
  136.   }, 4000)
  137.   // window.onresize = getHeatmap
  138. })
  139. // 创建搜索的api
  140. const theLocation = () => {
  141.   var city = document.getElementById('tipinput').value
  142.   if (city != '') {
  143.     // map.centerAndZoom({ lng: 110.404, lat: 36.915 }, 11)
  144.     // 必须输入完成的城市名才可以搜索 比如北京市
  145.     map.centerAndZoom(city, 11) // 用城市名设置地图中心点
  146.   }
  147. }
  148. // 创建提示的api
  149. function G(id) {
  150.   return document.getElementById(id)
  151. }
  152. // watch(map, () => {
  153. //   // getHeatmap()
  154. // })
  155. // 销毁阶段
  156. // onUnmounted(() => {
  157. //   echartHidden.value = true
  158. // })
  159. </script>
  160. <style scoped lang="scss">
  161. .border {
  162.   border-width: 0px;
  163.   left: 0px;
  164.   top: 0px;
  165.   background: inherit;
  166.   background-color: rgba(54, 62, 83, 1);
  167.   box-sizing: border-box;
  168.   border-width: 1px;
  169.   border-style: solid;
  170.   border-color: rgba(74, 124, 255, 1);
  171.   border-radius: 0px;
  172.   -moz-box-shadow: 2px 2px 3px rgba(74, 124, 255, 0.541176470588235);
  173.   -webkit-box-shadow: 2px 2px 3px rgba(74, 124, 255, 0.541176470588235);
  174.   box-shadow: 2px 2px 3px rgba(74, 124, 255, 0.541176470588235);
  175.   cursor: default !important;
  176. }
  177. #search {
  178.   z-index: 999;
  179.   position: absolute;
  180.   left: 233px;
  181.   top: 80px;
  182.   opacity: 1;
  183. }
  184. :deep(.ui_city_change_inner) {
  185.   position: relative;
  186.   height: 34px;
  187.   left: 280px;
  188.   top: 23px;
  189. }
  190. :deep(.BMap_CityListCtrl .citylist_popup_main) {
  191.   left: 280px;
  192.   top: 33px;
  193. }
  194. :deep(.ui_city_change_top .ui_city_change_inner) {
  195.   height: 30px;
  196.   line-height: 30px;
  197. }
  198. :deep(.BMap_stdMpType0 .BMap_stdMpZoom) {
  199.   top: 670px !important;
  200.   right: -1640px !important;
  201. }
  202. </style>

2.高德地图

代码如下:vue3项目中可以直接复制体验一下

  1. 高德地图引入的文件
  2.  <script type="text/javascript">
  3.     window._AMapSecurityConfig = {
  4.       securityJsCode: '786684d82538b07ac4d603654b118254',
  5.     }
  6.   </script>
  7.   <script type="text/javascript"
  8.     src="https://webapi.amap.com/maps?v=1.4.15&您自己的密钥&plugin=AMap.Autocomplete,AMap.PlaceSearch,AMap.ToolBar,AMap.DistrictSearch"></script>
  9.   <script type="text/javascript"
  10.     src="https://webapi.amap.com/loca?v=1.3.2&您自己的密钥"></script>
  11.   <script src="//a.amap.com/Loca/static/mock/heatmapData.js"></script>
  12.   <!-- 高德行政区选择控件 -->
  13.   <script type="text/javascript" src="https://webapi.amap.com/demos/js/liteToolbar.js"></script>
  14.   <!-- 高德地图的行政区搜索框 -->  
  15. 要主要这个css会影响其他组件,我的解决方案是把这个链接打开后,把对应的样式进行在对应 的组件中使用,一定要加scoped
  16.   <!-- <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" /> -->

  1. <template>
  2.   <div class="border">
  3.     <!-- v-if="echartHidden" -->
  4.     <div id="container" style="height: 80vh; width: 100%"></div>
  5.     <div id="search">
  6.       <a-input
  7.         v-model:value="searchValue"
  8.         @keyup.enter="seachAddress"
  9.         id="tipinput"
  10.         placeholder="请输入要搜索的位置"
  11.         style="width: 200px; margin: -1px 2px 0 12px"
  12.       />
  13.       <a-button type="primary" @click="seachAddress">
  14.         <template #icon><SearchOutlined /></template>
  15.       </a-button>
  16.     </div>
  17.     <div class="input-card">
  18.       <h4>行政区城市查询</h4>
  19.       <div class="input-item">
  20.         <div class="input-item-prepend"><span class="input-item-text">省市区</span></div>
  21.         <select id="province" style="width: 100px" @change="searchLocation"></select>
  22.       </div>
  23.       <div class="input-item">
  24.         <div class="input-item-prepend"><span class="input-item-text">地级市</span></div>
  25.         <select id="city" style="width: 100px" @change="searchLocation"></select>
  26.       </div>
  27.       <div class="input-item">
  28.         <div class="input-item-prepend"><span class="input-item-text">区县</span></div>
  29.         <select id="district" style="width: 100px" @change="searchLocation"></select>
  30.       </div>
  31.       <div class="input-item">
  32.         <div class="input-item-prepend"><span class="input-item-text">街道</span></div>
  33.         <select id="street" style="width: 100px" @change="setCenter"></select>
  34.       </div>
  35.     </div>
  36.   </div>
  37. </template>
  38. <script setup>
  39. import http from 'utils/request'
  40. // import './GaoDeMap.css'
  41. import { SearchOutlined } from '@ant-design/icons-vue'
  42. import { onMounted, ref, reactive } from 'vue'
  43. import AMapLoader from '@amap/amap-jsapi-loader'
  44. const url = {
  45.   hotreport: '/api-j/jindu/hotreport'
  46. }
  47. const searchValue = ref('')
  48. const lnglat = ref('')
  49. // const gdmap = reactive({})
  50. onMounted(() => {
  51.   getList()
  52. })
  53. var map,
  54.   district,
  55.   polygons = [],
  56.   citycode
  57. async function getList() {
  58.   const res = await http.get(url.hotreport, { params: {} })
  59.   if (res.code === 0) {
  60.     initMap(
  61.       res.data.map(el => {
  62.         return {
  63.           coordinate: [el.lng, el.lat],
  64.           count: el.value
  65.         }
  66.       })
  67.     )
  68.   }
  69. }
  70. var gdmap
  71. // 基础配置一下Echarts
  72. function initMap(data) {
  73.   //地图初始化
  74.   gdmap = new AMap.Map('container', {
  75.     resizeEnable: true, //是否监控地图容器尺寸变化
  76.     zoom: 12, //地图显示的缩放级别
  77.     zooms: [3, 18], //地图显示的缩放级别范围在PC上,默认为[3,18],取值范围[3-18];
  78.     viewMode: '2D', //默认为‘2D’,可选’3D’,选择‘3D’会显示 3D 地图效果
  79.     center: [116.397428, 39.90923] //地图中心点坐标
  80.   })
  81.   var layer = new Loca.HeatmapLayer({
  82.     map: gdmap
  83.   })
  84.   layer.setData(data, {
  85.     lnglat: 'coordinate',
  86.     value: 'count'
  87.   })
  88.   layer.setOptions({
  89.     style: {
  90.       radius: 16,
  91.       color: {
  92.         0.5: '#2c7bb6',
  93.         0.65: '#abd9e9',
  94.         0.7: '#ffffbf',
  95.         0.9: '#fde468',
  96.         1.0: '#d7191c'
  97.       }
  98.     }
  99.   })
  100.   layer.render()
  101.   var autoOptions = {
  102.     input: 'tipinput'
  103.   }
  104.   var auto = new AMap.Autocomplete(autoOptions)
  105.   var placeSearch = new AMap.PlaceSearch({
  106.     map: gdmap
  107.   }) //构造地点查询类
  108.   AMap.event.addListener(auto, 'select', select) //注册监听,当选中某条记录时会触发
  109.   function select(e) {
  110.     placeSearch.setCity(e.poi.adcode)
  111.     placeSearch.search(e.poi.name) //关键字查询查询
  112.   }
  113.   const toolBar = new AMap.ToolBar({
  114.     liteStyle: true
  115.   })
  116.   gdmap.addControl(toolBar)
  117. }
  118. const searchLocation = obj => {
  119.   console.log(obj)
  120.   //清除地图上所有覆盖物
  121.   for (var i = 0, l = polygons.length; i < l; i++) {
  122.     polygons[i].setMap(null)
  123.   }
  124.   // var option = obj[obj.target.selectedIndex];
  125.   let option = obj.target[obj.target.selectedIndex]
  126.   obj.target[obj.target.selectedIndex]
  127.   var keyword = option.text //关键字
  128.   var adcode = option.adcode
  129.   district.setLevel(option.value) //行政区级别
  130.   district.setExtensions('all')
  131.   //行政区查询
  132.   //按照adcode进行查询可以保证数据返回的唯一性
  133.   district.search(adcode, function (status, result) {
  134.     if (status === 'complete') {
  135.       getData(result.districtList[0], obj.target.id)
  136.     }
  137.   })
  138. }
  139. function setCenter(obj) {
  140.   let option = obj.target[obj.target.selectedIndex]
  141.   gdmap.setCenter(option.center)
  142. }
  143. //行政区划查询
  144. var opts = {
  145.   subdistrict: 1, //返回下一级行政区
  146.   showbiz: false //最后一级返回街道信息
  147. }
  148. district = new AMap.DistrictSearch(opts) //注意:需要使用插件同步下发功能才能这样直接使用
  149. district.search('中国', function (status, result) {
  150.   if (status == 'complete') {
  151.     getData(result.districtList[0])
  152.   }
  153. })
  154. function getData(data, level) {
  155.   var citySelect = document.getElementById('city')
  156.   var districtSelect = document.getElementById('district')
  157.   var areaSelect = document.getElementById('street')
  158.   var bounds = data.boundaries
  159.   if (bounds) {
  160.     for (var i = 0, l = bounds.length; i < l; i++) {
  161.       var polygon = new AMap.Polygon({
  162.         map: gdmap,
  163.         strokeWeight: 1,
  164.         strokeColor: '#0091ea',
  165.         fillColor: '#80d8ff',
  166.         fillOpacity: 0.2,
  167.         path: bounds[i]
  168.       })
  169.       polygons.push(polygon)
  170.     }
  171.     gdmap.setFitView() //地图自适应
  172.   }
  173.   //清空下一级别的下拉列表
  174.   if (level === 'province') {
  175.     citySelect.innerHTML = ''
  176.     districtSelect.innerHTML = ''
  177.     areaSelect.innerHTML = ''
  178.   } else if (level === 'city') {
  179.     districtSelect.innerHTML = ''
  180.     areaSelect.innerHTML = ''
  181.   } else if (level === 'district') {
  182.     areaSelect.innerHTML = ''
  183.   }
  184.   var subList = data.districtList
  185.   if (subList) {
  186.     var contentSub = new Option('--请选择--')
  187.     var curlevel = subList[0].level
  188.     var curList = document.querySelector('#' + curlevel)
  189.     curList.add(contentSub)
  190.     for (var i = 0, l = subList.length; i < l; i++) {
  191.       var name = subList[i].name
  192.       var levelSub = subList[i].level
  193.       var cityCode = subList[i].citycode
  194.       contentSub = new Option(name)
  195.       contentSub.setAttribute('value', levelSub)
  196.       contentSub.center = subList[i].center
  197.       contentSub.adcode = subList[i].adcode
  198.       curList.add(contentSub)
  199.     }
  200.   }
  201. }
  202. const seachAddress = () => {
  203.   if (searchValue.value != '') {
  204.     //清楚地图上的覆盖物
  205.     gdmap.clearMap()
  206.     console.log('搜索')
  207.     gdmap.plugin('AMap.PlaceSearch', () => {
  208.       let placeSearch = new AMap.PlaceSearch({
  209.         // city 指定搜索所在城市,支持传入格式有:城市名、citycode和adcode
  210.         city: '0797',
  211.         map: gdmap
  212.       })
  213.       let that = this
  214.       placeSearch.search(searchValue.value, function (status, result) {
  215.         // 查询成功时,result即对应匹配的POI信息
  216.         console.log(result)
  217.         var pois = result.poiList.pois
  218.         for (var i = 0; i < pois.length; i++) {
  219.           var poi = pois[i]
  220.           var marker = []
  221.           marker[i] = new AMap.Marker({
  222.             position: poi.location, // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
  223.             title: poi.name
  224.           })
  225.           // 将创建的点标记添加到已有的地图实例:
  226.           gdmap.add(marker[i])
  227.         }
  228.         gdmap.setFitView()
  229.         AMap.event.addListener(placeSearch, 'markerClick', function (data) {
  230.           console.log(data)
  231.           let result = data
  232.           //经纬度
  233.           let lng = result.event.lnglat.lng
  234.           let lat = result.event.lnglat.lat
  235.           lnglat.value = lng + ',' + lat
  236.           //地址
  237.           //   that.address = result.data.address;
  238.           //   //最近路口
  239.           //   that.nearestJunction = "";
  240.           //   //最近的路
  241.           //   that.nearestRoad = "";
  242.           //   //最近的POI
  243.           //   that.nearestPOI = "";
  244.         })
  245.       })
  246.     })
  247.   } else {
  248.     alert('请输入地址')
  249.   }
  250. }
  251. //判断浏览区是否支持canvas
  252. function isSupportCanvas() {
  253.   var elem = document.createElement('canvas')
  254.   return !!(elem.getContext && elem.getContext('2d'))
  255. }
  256. </script>
  257. <style scoped>
  258. .border {
  259.   border-width: 0px;
  260.   left: 0px;
  261.   top: 0px;
  262.   background: inherit;
  263.   background-color: rgba(54, 62, 83, 1);
  264.   box-sizing: border-box;
  265.   border-width: 1px;
  266.   border-style: solid;
  267.   border-color: rgba(74, 124, 255, 1);
  268.   border-radius: 0px;
  269.   -moz-box-shadow: 2px 2px 3px rgba(74, 124, 255, 0.541176470588235);
  270.   -webkit-box-shadow: 2px 2px 3px rgba(74, 124, 255, 0.541176470588235);
  271.   box-shadow: 2px 2px 3px rgba(74, 124, 255, 0.541176470588235);
  272. }
  273. #search {
  274.   z-index: 999;
  275.   position: absolute;
  276.   left: 233px;
  277.   top: 80px;
  278.   opacity: 0.8;
  279. }
  280. .amap-controls {
  281.   position: absolute;
  282.   bottom: 12px;
  283.   right: 12px;
  284. }
  285. .input-card {
  286.   bottom: 45rem !important;
  287. }
  288. html {
  289.   font-size: 12px;
  290. }
  291. .amap-copyright {
  292.   box-sizing: content-box;
  293. }
  294. * {
  295.   box-sizing: border-box;
  296. }
  297. .input-textarea {
  298.   color: grey;
  299.   height: 8em;
  300.   overflow: auto;
  301.   border-radius: 0.4rem;
  302.   border: 1px solid #ced4da;
  303.   margin-bottom: 1rem;
  304. }
  305. body {
  306.   margin: 0;
  307.   font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif,
  308.     'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  309.   line-height: 1.5;
  310.   font-weight: 300;
  311.   color: #111213;
  312. }
  313. hr {
  314.   margin: 0.5rem 0;
  315.   box-sizing: content-box;
  316.   height: 0;
  317.   overflow: visible;
  318.   border: 0;
  319.   border-top: 1px solid rgba(0, 0, 0, 0.1);
  320. }
  321. p {
  322.   margin-top: 0;
  323.   margin-bottom: 0;
  324. }
  325. label {
  326.   display: inline-block;
  327.   margin-bottom: 0.4rem;
  328. }
  329. label,
  330. .btn {
  331.   margin-left: 0;
  332.   font-size: 1rem;
  333. }
  334. button,
  335. input,
  336. select {
  337.   margin: 0;
  338.   font-family: inherit;
  339.   font-size: inherit;
  340.   line-height: inherit;
  341.   overflow: visible;
  342.   text-transform: none;
  343. }
  344. [type='button']::-moz-focus-inner,
  345. [type='reset']::-moz-focus-inner,
  346. [type='submit']::-moz-focus-inner,
  347. button::-moz-focus-inner {
  348.   padding: 0;
  349.   border-style: none;
  350. }
  351. input[type='checkbox'],
  352. input[type='radio'] {
  353.   box-sizing: border-box;
  354.   padding: 0;
  355.   -webkit-box-sizing: border-box;
  356.   box-sizing: border-box;
  357.   padding: 0;
  358.   margin: 0 0.5rem 0 0;
  359. }
  360. h4 {
  361.   font-family: inherit;
  362.   line-height: 1.8;
  363.   font-weight: 300;
  364.   color: inherit;
  365.   font-size: 1rem;
  366.   margin-top: 0;
  367.   margin-bottom: 0.5rem;
  368. }
  369. .btn {
  370.   display: inline-block;
  371.   font-weight: 400;
  372.   text-align: center;
  373.   white-space: nowrap;
  374.   vertical-align: middle;
  375.   -webkit-user-select: none;
  376.   -moz-user-select: none;
  377.   -ms-user-select: none;
  378.   user-select: none;
  379.   border: 1px solid transparent;
  380.   transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out,
  381.     box-shadow 0.15s ease-in-out;
  382.   background-color: transparent;
  383.   background-image: none;
  384.   color: #25a5f7;
  385.   border-color: #25a5f7;
  386.   padding: 0.25rem 0.5rem;
  387.   line-height: 1.5;
  388.   border-radius: 1rem;
  389.   -webkit-appearance: button;
  390.   cursor: pointer;
  391. }
  392. .btn:hover {
  393.   color: #fff;
  394.   background-color: #25a5f7;
  395.   border-color: #25a5f7;
  396. }
  397. .btn:hover {
  398.   text-decoration: none;
  399. }
  400. .input-item {
  401.   position: relative;
  402.   display: -ms-flexbox;
  403.   display: flex;
  404.   -ms-flex-wrap: wrap;
  405.   flex-wrap: wrap;
  406.   -ms-flex-align: center;
  407.   align-items: center;
  408.   width: 100%;
  409.   height: 3rem;
  410. }
  411. .input-item:last-child {
  412.   margin-bottom: 0;
  413. }
  414. .input-item > select,
  415. .input-item > input[type='text'],
  416. .input-item > input[type='date'] {
  417.   position: relative;
  418.   -ms-flex: 1 1 auto;
  419.   flex: 1 1 auto;
  420.   width: 1%;
  421.   margin-bottom: 0;
  422. }
  423. .input-item > select:not(:last-child),
  424. .input-item > input[type='text']:not(:last-child),
  425. .input-item > input[type='date']:not(:last-child) {
  426.   border-top-right-radius: 0;
  427.   border-bottom-right-radius: 0;
  428. }
  429. .input-item > select:not(:first-child),
  430. .input-item > input[type='text']:not(:first-child),
  431. .input-item > input[type='date']:not(:first-child) {
  432.   border-top-left-radius: 0;
  433.   border-bottom-left-radius: 0;
  434. }
  435. .input-item-prepend {
  436.   margin-right: -1px;
  437. }
  438. .input-item-text,
  439. input[type='text'],
  440. input[type='date'],
  441. select {
  442.   height: calc(2.2rem + 2px);
  443. }
  444. .input-item-text {
  445.   width: 6rem;
  446.   text-align: justify;
  447.   padding: 0.4rem 0.7rem;
  448.   display: inline-block;
  449.   text-justify: distribute-all-lines;
  450.   /*ie6-8*/
  451.   text-align-last: justify;
  452.   /* ie9*/
  453.   -moz-text-align-last: justify;
  454.   /*ff*/
  455.   -webkit-text-align-last: justify;
  456.   /*chrome 20+*/
  457.   -ms-flex-align: center;
  458.   align-items: center;
  459.   margin-bottom: 0;
  460.   font-size: 1rem;
  461.   font-weight: 400;
  462.   line-height: 1.5;
  463.   color: #495057;
  464.   text-align: center;
  465.   white-space: nowrap;
  466.   background-color: #e9ecef;
  467.   border: 1px solid #ced4da;
  468.   border-radius: 0.25rem;
  469.   border-bottom-right-radius: 0;
  470.   border-top-right-radius: 0;
  471. }
  472. .input-item-text input[type='checkbox'],
  473. .input-item-text input[type='radio'] {
  474.   margin-top: 0;
  475. }
  476. .input-card {
  477.   display: flex;
  478.   flex-direction: column;
  479.   min-width: 0;
  480.   word-wrap: break-word;
  481.   background-color: #fff;
  482.   background-clip: border-box;
  483.   border-radius: 0.25rem;
  484.   width: 18rem;
  485.   border-width: 0;
  486.   border-radius: 0.4rem;
  487.   box-shadow: 0 2px 6px 0 rgba(114, 124, 245, 0.5);
  488.   position: fixed;
  489.   bottom: 1rem;
  490.   right: 1rem;
  491.   -ms-flex: 1 1 auto;
  492.   flex: 1 1 auto;
  493.   padding: 0.75rem 1.25rem;
  494. }
  495. .input-text {
  496.   line-height: 2rem;
  497.   margin-right: 2rem;
  498. }
  499. .info hr {
  500.   margin-right: 0;
  501.   margin-left: 0;
  502.   border-top-color: grey;
  503. }
  504. .info {
  505.   padding: 0.75rem 1.25rem;
  506.   margin-bottom: 1rem;
  507.   border-radius: 0.25rem;
  508.   position: fixed;
  509.   top: 1rem;
  510.   background-color: white;
  511.   width: auto;
  512.   min-width: 22rem;
  513.   border-width: 0;
  514.   right: 1rem;
  515.   box-shadow: 0 2px 6px 0 rgba(114, 124, 245, 0.5);
  516. }
  517. .code {
  518.   left: 1.5rem;
  519.   right: 1.5rem;
  520.   top: 1.5rem;
  521.   bottom: 1.5rem;
  522.   overflow: auto;
  523.   margin-bottom: 0rem;
  524. }
  525. .code .btn {
  526.   top: 1rem;
  527.   position: absolute;
  528.   right: 1rem;
  529. }
  530. .code .result {
  531.   border: 1px solid rgba(0, 0, 0, 0.1);
  532.   border-radius: 0.5rem;
  533.   padding: 1rem;
  534.   bottom: 1rem;
  535.   position: absolute;
  536.   top: 5.5rem;
  537.   right: 1rem;
  538.   left: 1rem;
  539.   overflow: auto;
  540. }
  541. .code .status {
  542.   color: #80adff;
  543.   display: inline-block;
  544.   font-size: 14px;
  545. }
  546. .code h4 {
  547.   display: inline-block;
  548.   max-width: 10rem;
  549.   margin-right: 1rem;
  550.   margin-bottom: 1rem;
  551. }
  552. select,
  553. input[type='text'],
  554. input[type='date'] {
  555.   display: inline-block;
  556.   width: 100%;
  557.   padding: 0.375rem 1.75rem 0.375rem 0.75rem;
  558.   line-height: 1.5;
  559.   color: #495057;
  560.   vertical-align: middle;
  561.   background: #fff
  562.     url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E")
  563.     no-repeat right 0.75rem center;
  564.   background-size: 8px 10px;
  565.   border: 1px solid #ced4da;
  566.   border-radius: 0.25rem;
  567.   -webkit-appearance: none;
  568.   -moz-appearance: none;
  569.   appearance: none;
  570. }
  571. input[type='text'],
  572. input[type='date'] {
  573.   background: #fff;
  574.   padding: 0.375rem 0.75rem;
  575. }
  576. select:focus,
  577. input[type='text']:focus,
  578. input[type='date']:focus {
  579.   border-color: #80bdff;
  580.   outline: 0;
  581.   box-shadow: 0 0 0 0.1rem rgba(128, 189, 255, 0.1);
  582. }
  583. .btn:focus {
  584.   outline: 0;
  585.   box-shadow: none;
  586. }
  587. select:focus::-ms-value,
  588. input[type='text']:focus::-ms-value,
  589. input[type='date']:focus::-ms-value {
  590.   color: #495057;
  591.   background-color: #fff;
  592. }
  593. /* native toastr */
  594. .native-toast {
  595.   position: fixed;
  596.   background-color: rgba(50, 50, 50, 0.8);
  597.   border-radius: 33px;
  598.   color: white;
  599.   left: 50%;
  600.   text-align: center;
  601.   padding: 6px 12px;
  602.   opacity: 0;
  603.   z-index: 99999;
  604.   transition: transform 0.25s, opacity 0.25s, top 0.25s;
  605.   box-sizing: border-box;
  606. }
  607. .native-toast-bottom {
  608.   bottom: 50px;
  609.   -ms-transform: translateX(-50%) translateY(50px);
  610.   transform: translateX(-50%) translateY(50px);
  611. }
  612. .native-toast-bottom.native-toast-shown {
  613.   opacity: 1;
  614.   -ms-transform: translateX(-50%) translateY(0);
  615.   transform: translateX(-50%) translateY(0);
  616. }
  617. .native-toast-bottom.native-toast-edge {
  618.   bottom: 0;
  619. }
  620. .native-toast-top {
  621.   top: 50px;
  622.   -ms-transform: translateX(-50%) translateY(-50px);
  623.   transform: translateX(-50%) translateY(-50px);
  624. }
  625. .native-toast-top.native-toast-shown {
  626.   opacity: 1;
  627.   -ms-transform: translateX(-50%) translateY(0);
  628.   transform: translateX(-50%) translateY(0);
  629. }
  630. .native-toast-top.native-toast-edge {
  631.   top: 0;
  632. }
  633. .native-toast-center {
  634.   top: 0;
  635.   -ms-transform: translateX(-50%) translateY(-50px);
  636.   transform: translateX(-50%) translateY(-50px);
  637. }
  638. .native-toast-center.native-toast-shown {
  639.   opacity: 1;
  640.   top: 50%;
  641.   -ms-transform: translateX(-50%) translateY(-50%);
  642.   transform: translateX(-50%) translateY(-50%);
  643. }
  644. .native-toast-edge {
  645.   border-radius: 0;
  646.   width: 100%;
  647.   text-align: left;
  648. }
  649. @media screen and (min-width: 40rem) {
  650.   .native-toast:not(.native-toast-edge) {
  651.     max-width: 18rem;
  652.   }
  653. }
  654. /*
  655.   max-width does not seem to work in small screen?
  656. */
  657. /*@media screen and (max-width: 768px) {
  658.   .native-toast:not(.native-toast-edge) {
  659.     max-width: 400px;
  660.   }
  661. }
  662. @media screen and (max-width: 468px) {
  663.   .native-toast:not(.native-toast-edge) {
  664.     max-width: 300px;
  665.   }
  666. }*/
  667. /* types */
  668. .native-toast-error {
  669.   background-color: #d92727;
  670.   color: white;
  671. }
  672. .native-toast-success {
  673.   background-color: #62a465;
  674.   color: white;
  675. }
  676. .native-toast-warning {
  677.   background-color: #fdaf17;
  678.   color: white;
  679. }
  680. .native-toast-info {
  681.   background-color: #5060ba;
  682.   color: white;
  683. }
  684. [class^='native-toast-icon-'] {
  685.   vertical-align: middle;
  686.   margin-right: 8px;
  687. }
  688. [class^='native-toast-icon-'] svg {
  689.   width: 16px;
  690.   height: 16px;
  691. }
  692. </style>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/155745
推荐阅读