返回上一页:
<button onclick="goBack()">返回上一页</button>
<script>
function goBack(){
window.history.go(-1) -2即为退后2页
}
</script>
点击回到顶部
// 页面回到顶部
document.body.scrollTop = 0
document.documentElement.scrollTop = 0
// 某个div回到顶部
document.getElementById('divBox').scrollTop = 0
- 解决办法:
this.$nextTick(() => {
document.getElementById('videoBox').scrollTop = 0
})
a标签跳转锚点到页面指定位置
https://blog.csdn.net/wangweiscsdn/article/details/55100448
正则
if (!patrn.test(this.inputValue)) {
_g.toastMsg('warning', '场号必须是数字')
return
}
let arr = this.inputValue.split('')
if (arr.length !== 3) {
_g.toastMsg('warning', '长度在3个字符')
return
}
if (!this.inputValue) {
_g.toastMsg('warning', '请输入场号/集号')
return
}
- 正则表达式纯数字校验 JS
https://blog.csdn.net/wangming520liwei/article/details/53168140 - 判断数字是否为两位数
https://blog.csdn.net/sinat_39417731/article/details/78266410
JS获取HTML DOM元素的8种方法
let odiv = document.getElementById('id')
odiv.style.color = '#000'
https://www.jb51.net/article/116460.htm
获取鼠标点击位置坐标
https://www.cnblogs.com/dolphinX/archive/2012/10/09/2717119.html
js 点击事件
document.getElementById("jsOnClick").onclick = clickHandler2;
https://www.cnblogs.com/wenb/p/5956243.html
键盘按下事件(keydown)
$(document).keydown(function(event){
if(event.keyCode == 13){
alert('你按下了Enter');
}
});
https://www.cnblogs.com/pangpanghuan/p/6423204.html
js跳转页面与打开新窗口的方法
window.open("http://www.jb51.net"); //在另外新建窗口中打开窗口
window.location.href="http://www.jb51.net"; //在同当前窗口中打开窗口
https://www.cnblogs.com/lijshui/p/7451360.html
原生js动态添加元素标签及设置属性
https://www.cnblogs.com/cllgeek/articles/5859908.html
删除div中的内容 ,但是保留这个div
$('#test').empty(); //jQuery
https://zhidao.baidu.com/question/289778640.html
js 获取checkbox 所有选中的值
function show(){
obj = document.getElementsByName("test");
check_val = [];
for(k in obj){
if(obj[k].checked)
check_val.push(obj[k].value);
}
alert(check_val);
}
https://www.cnblogs.com/sunxirui00/p/7498014.html
ajax请求,返回值为304 Not Modified 错误原因与解决办法
https://blog.csdn.net/u011724770/article/details/54948748
页面所有图片禁止右键(防止保存等)
- jquery
$('img').bind("contextmenu", function(e){ return false; });
https://blog.csdn.net/gongqinglin/article/details/54290279
- js
var imgs=document.querySelectorAll("img");
for(var i=0;i<imgs.length;i++){
imgs[i].onmousedown = function (e) {
if (e.which == 3) {// 鼠标右键
console.log('right')
this.oncontextmenu = function () { return false; }
}
}
}
https://www.cnblogs.com/dxzg/p/9930559.html、
获取当前页面url并截取所需字段
let url = window.location.href; // 动态获取当前url
let obj = {};
let reg = /[?&][^?&]+=[^?&]+/g;
let arr = url.match(reg);
if (arr) {
arr.forEach(item => {
let tempArr = item.substring(1).split("=");
let key = decodeURIComponent(tempArr[0]);
let val = decodeURIComponent(tempArr[1]);
obj[key] = val;
});
},
this.type= obj.type; // 截取所需字段并赋值
https://blog.csdn.net/weixin_30663471/article/details/99272489
js随机点名
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
<script>
function num(){
var name = ["张三","张四","张五","张刘","张七","张八","张九","李三","李四","李武"];
i=Math.floor(Math.random()*name.length);
document.write(name[i]);
}
num();
</script>
https://blog.csdn.net/h5_since/article/details/89852303
获取和更改页面Url地址栏后面的参数
- var urlIndex = document.location.href; //获取地址栏地址
document.location.hash = "?page="+1; //更改地址栏地址
//替换指定传入参数的值,paramName为参数,replaceWith为新值
function replaceParamVal(paramName,replaceWith) {
var oUrl = this.location.href.toString();
var re=eval('/('+ paramName+'=)([^&]*)/gi');
var nUrl = oUrl.replace(re,paramName+'='+replaceWith);
this.location = nUrl;
window.location.href=nUrl
}
调用方法:replaceParamVal("vid", vid)
https://blog.csdn.net/second_boy/article/details/50832725
HTTP请求中Request Payload和Form Data的区别
- 1、FormData和Payload是浏览器传输给接口的两种格式,这两种方式浏览器是通过Content-Type来进行区分的。
如果是application/x-www-form-urlencoded的话,则为formdata方式;
如果是applocation/json或multipart/form-data的话,则为request payload方式。 - 2、使用ajax方式提交post请求的代码(默认使用application/x-www-form-urlencoded编码),则为formdata请求
- 3、使用multipart/form-data表单上传文件,则为request payload方式
- 4、使用content-type:application/json编码,则为request payload方式
https://blog.csdn.net/xue_yanan/article/details/92980561
配置浏览器头部小图标
//www.greatytc.com/p/3c6154480c0c
textarea 失去焦点
<textarea name="" id="remark" cols="" rows="" @blur="textareaBlur" @focus="textareaFocus"></textarea>
https://blog.csdn.net/b671900/article/details/26251921
axios的get与post网络请求
axios.get('/sys/user/login', {
params: this.search
}).then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
})
axios.post('/sys/user/list', this.search).then((res) => {
console.log(res.data)
if (res.data.code === 0) {
this.tableData = res.data.data
}
}).catch((error)=> {
})
https://blog.csdn.net/qq_41115965/article/details/80780264
纯CSS3使用vw和vh视口单位实现自适应
http://caibaojian.com/vw-vh.html
移动web适配之--vh,vw,vmin,vmax
https://www.nihaoshijie.com.cn/index.php/archives/788/
html5浏览器less应用
https://www.cnblogs.com/WhiteM/p/6187102.html
js 当变量值为0,判断是否为空时(0=="")返回ture的问题
https://blog.csdn.net/fengsx0521/article/details/81239488
JS实现拖动图片
https://blog.csdn.net/qq_33665647/article/details/52089526
下载文件到本地
window.location.href = window.HOST + res.data
- res.data为后台返回的路径
下载图片或者视频到本地
- a标签
<a href="图片/视频路径" download="图片/视频名称">
https://segmentfault.com/q/1010000010493203
- html中的js:
js循环读取json数据,将读取到的数据用js写成表格https://www.cnblogs.com/yuanxinru321/p/7306556.html
js操作select下拉列表
https://blog.csdn.net/qq_40910788/article/details/84575610
less 定义变量用法
- 定义变量
@color: red;
p {
color: @color; // 编译为 color: red;
}
JSONPath — $(仅限了解)
JsonPath表达式总是以与XPath表达式结合使用XML文档相同的方式引用JSON结构。
JsonPath中的“根成员对象”始终称为.store.book [0].title
或括号表示法
$['store']['book'][0]['title']
https://blog.csdn.net/lwg_1540652358/article/details/84111339