返回上一頁:
<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標簽跳轉(zhuǎn)錨點到頁面指定位置
https://blog.csdn.net/wangweiscsdn/article/details/55100448
正則
if (!patrn.test(this.inputValue)) {
_g.toastMsg('warning', '場號必須是數(shù)字')
return
}
let arr = this.inputValue.split('')
if (arr.length !== 3) {
_g.toastMsg('warning', '長度在3個字符')
return
}
if (!this.inputValue) {
_g.toastMsg('warning', '請輸入場號/集號')
return
}
- 正則表達式純數(shù)字校驗 JS
https://blog.csdn.net/wangming520liwei/article/details/53168140 - 判斷數(shù)字是否為兩位數(shù)
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跳轉(zhuǎn)頁面與打開新窗口的方法
window.open("http://www.jb51.net"); //在另外新建窗口中打開窗口
window.location.href="http://www.jb51.net"; //在同當前窗口中打開窗口
https://www.cnblogs.com/lijshui/p/7451360.html
原生js動態(tài)添加元素標簽及設(shè)置屬性
https://www.cnblogs.com/cllgeek/articles/5859908.html
刪除div中的內(nèi)容 蝗蛙,但是保留這個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; // 動態(tài)獲取當前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地址欄后面的參數(shù)
- var urlIndex = document.location.href; //獲取地址欄地址
document.location.hash = "?page="+1; //更改地址欄地址
//替換指定傳入?yún)?shù)的值,paramName為參數(shù),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
}
調(diào)用方法:replaceParamVal("vid", vid)
https://blog.csdn.net/second_boy/article/details/50832725
HTTP請求中Request Payload和Form Data的區(qū)別
- 1早直、FormData和Payload是瀏覽器傳輸給接口的兩種格式做院,這兩種方式瀏覽器是通過Content-Type來進行區(qū)分的。
如果是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
配置瀏覽器頭部小圖標
http://www.reibang.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網(wǎng)絡(luò)請求
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視口單位實現(xiàn)自適應(yīng)
http://caibaojian.com/vw-vh.html
移動web適配之--vh,vw,vmin,vmax
https://www.nihaoshijie.com.cn/index.php/archives/788/
html5瀏覽器less應(yīng)用
https://www.cnblogs.com/WhiteM/p/6187102.html
js 當變量值為0豪筝,判斷是否為空時(0=="")返回ture的問題
https://blog.csdn.net/fengsx0521/article/details/81239488
JS實現(xiàn)拖動圖片
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循環(huán)讀取json數(shù)據(jù),將讀取到的數(shù)據(jù)用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表達式結(jié)合使用XML文檔相同的方式引用JSON結(jié)構(gòu)摘能。
JsonPath中的“根成員對象”始終稱為.store.book [0].title
或括號表示法
$['store']['book'][0]['title']
https://blog.csdn.net/lwg_1540652358/article/details/84111339