• 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)

  • 相关阅读:
    2021-09-24有史以来最小的人造飞行结构:有翅膀的微芯片
    go gin r.Any Query PostForm Param获取请求参数
    微信小程序的民宿客房预订uniapp小程序
    SpringCloudAlibaba注册中心与配置中心之利器Nacos实战与源码分析(下)
    dBm和asu关系
    Spring-ReactiveKafkaConsumer(反应式消费kafka消息)
    进制转换问题
    【Java面试】Mysql为什么使用B+Tree作为索引结构
    2024年浙大MPA复试可能面临的变数:权重加大
    每日一题:无感刷新页面(附可运行的前后端源码,前端vue,后端node)
  • 原文地址:https://blog.csdn.net/m0_74149462/article/details/133882354