• js中函数多参数的简化


     1

    1. function createPerson({ name = "Unknown", age = 0, gender = "Unknown", ...other }) {
    2. return { name, age, gender, other };
    3. }
    4. const person = createPerson({ name: "John", age: 30, gender: "male", occupation: "developer", hobbies: ["reading", "traveling"] });
    5. console.log(person)

    2

    1. /**
    2. * @Event 方法
    3. * @description: 更换点位图标、并将点击的点位移动到地图中心
    4. * @params: latLog:经纬度(非字符串) { lat: e.latitude, lng: e.longitude }
    5. * @params: data: 传递给选中图标点击出现的弹窗的数据(passData.data) data:{data: {}, type: "视频监控"}
    6. * @param: type: 4 视频监控 2 信息屏 3 路口 1 停车场
    7. * @param: imgType: 图片名称Choose.png
    8. * */
    9. setMapCenter(params) {
    10. const { latLog, data, imgType, type } = params
    11. console.log(latLog, data, imgType, type, "setMapCenter");
    12. this.map.panTo(latLog);
    13. this.removeSearchMarker();
    14. var markerIcon = "";
    15. markerIcon = L.divIcon({
    16. className: "markerBox",
    17. html: `
      ${imgType}\" />
      `
      ,
    18. iconSize: [40, 40],
    19. });
    20. this.searchMarker = new L.Marker(latLog, { icon: markerIcon });
    21. this.map.addLayer(this.searchMarker);
    22. this.searchMarker.setZIndexOffset(10000); // 设置层级以防被覆盖
    23. let that = this;
    24. this.searchMarker.on("click", function () {
    25. /* 选中后的图标点击事件 */
    26. if (type == 1) {
    27. let passData = {
    28. data: data.data,
    29. type: "停车场",
    30. };
    31. /* 打开停车场详情的弹窗 */
    32. that.$refs.parkingDialog.showDialog(passData);
    33. }
    34. if (type == 2) {
    35. let passData = {
    36. data: data.data,
    37. type: "信息屏",
    38. };
    39. /* 打开信息屏详情的弹窗 */
    40. that.$refs.screenDialog.showDialog(passData);
    41. }
    42. if (type == 3) {
    43. let passData = {
    44. data: data.data,
    45. type: "路口",
    46. };
    47. /* 打开路口详情的弹窗 */
    48. that.$refs.intersectionDialog.showDialog(passData);
    49. }
    50. if (type == 4) {
    51. let passData = {
    52. data: data.data,
    53. type: "视频监控",
    54. };
    55. /* 打开视频监控详情的弹窗 */
    56. that.$refs.monitorDialog.showDialog(passData);
    57. }
    58. });
    59. },
    60. let obj = {
    61. latLog: {
    62. lat: parseFloat(item.latitude),
    63. lng: parseFloat(item.longitude),
    64. },
    65. data: {
    66. data: {
    67. ...item,
    68. id: item.searchId,
    69. code: item.searchCode
    70. },
    71. type: typeList.find(e => e.interfaceType === item.searchType).type
    72. },
    73. imgType: typeList.find(e => e.interfaceType === item.searchType).imgType + "Choose.png",
    74. type: typeList.find(e => e.interfaceType === item.searchType).searchType
    75. }
    76. this.$emit("setMapCenter", obj)

  • 相关阅读:
    进程控制的一些具体操作
    山海鲸汽车需求调研系统:智慧决策的关键一步
    【Java EE】JUC(java.util.concurrent) 的常见类
    038:vue页面头部提示低版本浏览器升级问题
    Python视频剪辑-Moviepy安装和基础使用
    docker下快速部署openldap与PHPLdapAdmin
    什么是无损检测设备?
    秋招Java后端开发冲刺——非关系型数据库篇(Elasticsearch)
    竞赛 题目:基于LSTM的预测算法 - 股票预测 天气预测 房价预测
    iOS自动化打包 Jenkins+Gitlab+Fastlane+蒲公英+钉钉
  • 原文地址:https://blog.csdn.net/m0_74149462/article/details/133882354