js
w15228212327_cc
这个作者很懒,什么都没留下…
展开
-
spread和剩余参数rest的区别
当我们在代码中看到"..."时,它要么是 rest 参数,要么就是 spread 语法。有一个简单的方法可以区分它们:若...出现在函数参数列表的最后,那么它就是 rest 参数,它会把参数列表中剩余的参数收集到一个数组中。 若...出现在函数调用或类似的表达式中,那它就是 spread 语法,它会把一个数组展开为列表。使用场景:Rest 参数用于创建可接受任意数量参数的函数。 例如,我们需要把所有的参数都放到数组args中:(Rest 参数必须放到参数列表的末尾)...原创 2021-04-15 09:42:01 · 144 阅读 · 0 评论 -
map标注引入图片及修改引入图片的大小
map.centerAndZoom(point, 15);var myIcon = new BMap.Icon("${systemConfig.cssUrl}/static/kzguicom/wap/images/mapIcon.png",newBMap.Size(28,34),{//图片大小 anchor: new BMap.Size(10,10) //标注相对point的偏移位置});myIcon.setImageSize(new BMap.Size(28...原创 2021-03-09 11:23:03 · 421 阅读 · 0 评论 -
jq获取元素距顶部距离
//元素到文档顶部距离$('element').offset().top;//当前窗口滚动条的高度$(window).scrollTop();原创 2020-12-22 14:45:31 · 1322 阅读 · 0 评论 -
生成从minNum到maxNum的随机数
function randomNum(minNum,maxNum){ switch(arguments.length){ case 1: return parseInt(Math.random()*minNum+1,10); break; case 2: return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10.原创 2020-12-08 09:18:18 · 223 阅读 · 0 评论 -
锚链接平滑跳转并且去掉#
$(function(){ $('a[href*=#]').click(function() { console.log(this.pathname) if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { var $target = $(...原创 2020-12-08 08:29:11 · 185 阅读 · 0 评论 -
js回到顶部或者跳转到页面某个位置高度平滑跳转
window.scrollTo({ top: 750, behavior: "smooth" });原创 2020-12-08 08:27:21 · 896 阅读 · 0 评论 -
js如何直接打开百度地图app进行导航
只需要知道自己要到的目的地的经纬度,就可以直接打开地图;注意:经纬度位置不要写反了window.location.href ="http://api.map.baidu.com/marker?location=29.539792,106.519852&title=泉州xx科技有限公司&content=泉州xx科技有限公司&output=html"...原创 2020-12-08 08:14:55 · 1435 阅读 · 0 评论