1.模糊搜索
option.toUpperCase().indexOf(value.toUpperCase()) !== -1;
2.打印功能
let newWindow = window.open('_blank')
let codeStr = this.$refs.home.innerHTML
newWindow.document.write(codeStr)
newWindow.document.close()
newWindow.print()
return true3.moment.js常用代码收集
let startDay = this.moment().add(-6, 'days').format('YYYY-MM-DD')
let endDate = this.moment().add(-1, 'days').format('YYYY-MM-DD')
this.week = this.moment().format('ddd')
this.weekday = this.moment().format('dddd')
this.year = this.moment().format('YYYY')
this.day = this.moment().format('MM-DD')
4.iconmoon图标的使用
1、将一些图片做成svg图,但是在项目中不会直接使用svg图片,而是会先制作成图标字体,然后在css样式里边进行引入。
2、打开https://icommoon.io上传做好的svg图片,然后制作成font字体,下载下来。
3、将解压缩后的font文件夹里边的四个文件都拷贝到项目中,加上style.css即可,放在stylus文件夹里边并改名修改。
4、相关信息可以在vue代码里边看到
5.window关掉运行的端口
1、CMD>netstat -ano | findstr 8080找到相应的进程号,如1234
2、CMD>taskkill /F /PID 1234
6.移动端开发前面要加的meta代码
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">7.手机实现预览方式
1、找到自己的ip地址,然后将网址上面的localhost改成192.168.0.26(例子),也就是改成自己的ip地址,之后将网址复制到草料文本二维码生成器即可。
2、同时要达到的要求是手机也要链接在相应的wifi下面,才可以形成访问
3、可以用phpstudy进行实现8.判断鼠标滚动方向
var oldValue = 0
var nowValue = 0
$(window).scroll(function(e){
nowValue = $(this).scrollTop()
if(oldValue<nowValue){
console.log('向下滚动')
} else {
console.log('向上滚动')
}
setTimeout(function(){oldValue=nowValue},0)
})
9.图片上传代码
<!DOCTYPE html>
<html>
<head>
<title>HTML5上传图片预览</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://www.codefans.net/ajaxjs/jquery-1.6.2.min.js"></script>
</head>
<body>
<h3>请选择图片文件:JPG/GIF</h3>
<form name="form0" id="form0" >
<input type="file" name="file0" id="file0" multiple="multiple" /><br><img src="" id="img0" >
</form>
<script>
$("#file0").change(function(){
var objUrl = getObjectURL(this.files[0]) ;
console.log("objUrl = "+objUrl) ;
if (objUrl) {
$("#img0").attr("src", objUrl) ;
}
}) ;
//建立一個可存取到該file的url
function getObjectURL(file) {
var url = null ;
if (window.createObjectURL!=undefined) { // basic
url = window.createObjectURL(file) ;
} else if (window.URL!=undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(file) ;
} else if (window.webkitURL!=undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(file) ;
}
return url ;
}
</script>
</body>
</html>
10.文件相关
let inputDOM = this.$refs.inputer
let myData = new FormData()
myData.append('processDefId', 'IMMEJH5J-DR5CEL4-R4WUQB1')
myData.append('file', inputDOM.files[0])
this.uploadFile(api.attachmentUpload, myData)
let imgUrl = window.URL.createObjectURL(inputDOM.files[0])
this.$store.commit('saveCoverImgUrl', imgUrl)