js
码林鼠
致力于知识的传播
展开
-
typescript
ts原创 2022-12-07 20:11:37 · 366 阅读 · 0 评论 -
umi预渲染
umi官网有预渲染,但是,是基于服务端渲染的,如果服务端渲染实现不了,那预渲染别谈,即使可以,但也不能指定路由渲染指定页面。在执行yarn build之后就可以渲染出about/indext.html页面。下面采用插件的形式实现。原创 2022-09-29 10:59:37 · 614 阅读 · 0 评论 -
package-lock.json的作用
有两个优点:有了package-lock.json,那么在npm install就会更快锁定版本号快:是因为这里记录了所有的依赖包,因为某些依赖有子依赖孙依赖,要等子依赖安装完才知道孙依赖,但是有了package-lock.json,就无需等待子依赖的下载就直接可以知道孙依赖,从而提高速度锁:有了package-lock.json就可以根据package-lock.json中的版本号进行安装,不会因为版本升级而导致项目异常假设没有package-lock.json:在npm install的时原创 2020-12-27 22:29:19 · 397 阅读 · 0 评论 -
nodejs
httpvar http = require('http')var fs = require('fs')var server = http.createServer()server.on('request',function(req,res){ console.log('requesting')//这是在服务器端打印 // res.write('hello malinshu') // res.end()//一定要end,浏览器在访问的时候才会显示在窗口上 // res原创 2020-07-05 18:00:11 · 96 阅读 · 0 评论 -
websocket及时通讯
基础var WebSocketServer = require('websocket').server;var http = require('http');var server = http.createServer(function(request, response) {});server.listen(3000, function() { console.log('服务器启...原创 2019-11-10 23:05:06 · 111 阅读 · 0 评论 -
exports和module.exports的区别
情况一,指向相同存储空间其实,刚开始的时候exports和module.exports是等价的,指向同一块内存给exports和module.exports定义变量name和tall其实定义到了同一块内存情况二,指向不同存储空间当给exports和module.exports赋值时,就重新开辟了一个新的空间,各自占有各自的空间a.js文件导出的就只有name属性那为什么不是导出tall属性,因为文件的最终都是导出module.exports对象,所以只导出了module.exports的属性原创 2020-12-27 11:50:50 · 136 阅读 · 0 评论 -
process.env.NODE_ENV配置
vue2.x配置vue 3.x配置原创 2020-12-01 14:59:30 · 867 阅读 · 0 评论 -
process.env.NODE_ENV环境变量vue2.x
然后,通过npm run build打包后将dist放到wamp服务器中process.env.NODE_ENV的值就自动变为production原创 2020-12-25 01:02:42 · 593 阅读 · 0 评论 -
nodejs实战入门教程
项目目录G:\FIR_NODE_APP│ app.js//入口文件│ package.json//第三方依赖包管理文件,在根目录下运行cnpm init就有此文件├─models│ User.js//模型类(本案例以mongodb作为数据库,mongodb以模型类操作数据库)├─public//静态文件包│ │ main.css//css样式│ └─js│ ...原创 2019-09-13 10:58:12 · 1156 阅读 · 0 评论 -
node中require的加载规则加载顺序
首先讲一下require的路径参数可以为什么内容:核心模块,如fs,path,http等nodejs自己的模块开发者的文件(以下称路径模块),也就是用相对路径或者绝对路径引入的node_modules中的第三方模块,这是通过npm下载的缓存中的模块(这些模块是已经有require加载过的,直接从内容拿更快,这也是node的设计规则)好了,既然我们知道require(path)中,path可以有什么内容,那就讲一下加载的优先级require加载顺序:缓存中的模块,核心模块,路径模块,node原创 2020-12-27 11:36:31 · 889 阅读 · 3 评论 -
post请求变成option的解决方法
配置一下content-typeaxios.defaults.headers[‘Content-Type’] = ‘application/x-www-form-urlencoded; charset=UTF-8’原创 2020-01-03 23:44:14 · 3677 阅读 · 0 评论 -
封装axios
http.jsimport axios from 'axios'axios.defaults.baseURL = 'http://127.0.0.1:2000'axios.defaults.timeout = 5000axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UT...原创 2019-09-13 08:55:15 · 1471 阅读 · 0 评论 -
axios传递formdata格式问题
处理前:处理后:方法:用axios自带的qs转化一下import qs from 'qs';axios.post(url, qs.stringify(params))原创 2020-02-16 22:11:41 · 1054 阅读 · 0 评论 -
jquery强劲基础
$(document).ready() 是个什么函数?ready() 函数在DOM树 完全加载后执行JavaScript window.onload 事件和 jQuery ready 函数有何不同?window.onload除了要等待 DOM 被创建还要等其他外部资源都完全加载。remove()和detach()的区别remove同时将元素和元素绑定的事件移除,而detach没有将事件...原创 2020-04-02 13:20:17 · 109 阅读 · 0 评论 -
自己封装jq插件
packjq.js(function($){ $.fn.bgColor = function(colorValue){//给jQuery的原型添加方法 //this指向调用bgColor的对象 this.css('backgroundColor',colorValue) return this//返回jquery对象就可以进行链式编程...原创 2020-04-02 22:40:50 · 147 阅读 · 0 评论 -
js双等号==和三等号===
基本数据类型const a = 'malinshu'const b = 'malinshu'a === b // truea==b //trueconst num1 = 111const num2 = 111num1 == num2 // truenum1 === num2 // trueconst b1 = trueconst b2 = trueb1 == b2 // trueb1 === b2 // truenull === undefined //falsenull原创 2022-02-18 11:14:34 · 437 阅读 · 0 评论 -
requestAnimationFrame无限循环pk定时器
requestAnimationFrame到底比起定时器来说有什么样的优势,大家不妨网上查阅一番,在次之前做个实践,定将大有收益,请看以下内容:let num = 0const run = () => { console.log('run') if (num % 60 === 0) { console.log(new Date()) } num += 1 requestAnimationFrame(run)}requestAnimationFrame(run)原创 2021-08-17 22:27:59 · 243 阅读 · 0 评论 -
ECMAScript 6 es6 必知知识
let和const一样,定义的变量在本区域内有效,无法变量提升,同一作用域内不能定义相同的变量名不同的是,const定义的时候必须马上赋值var声明的变量有提升能力,不管在哪里声明都视为顶部声明,所以如下的’ma’会被’linshu’覆盖,全局变量就是window的属性,window.name{ { var name = "ma"; { var name ...原创 2020-04-05 22:55:30 · 142 阅读 · 1 评论 -
防抖与节流
防抖function debounce(fn, wait) { console.log('改变窗口大小的过程中,这行不执行,只在页面渲染的时候执行了一次') let timer = null; return function () { if (timer !== null) { console.log('改变窗口大小的过程中一直执行这行') clearTimeout(timer); }原创 2021-01-28 10:34:53 · 65 阅读 · 0 评论 -
three.js
import * as THREE from 'three';window.THREE = THREEimport {WEBGL} from './WEBGL'window.WEBGL = WEBGLif (WEBGL.isWebGLAvailable()) {//检测浏览器是否支持3d(three.js是基于WEBGL的实现https://github.com/mrdoob/three.js/blob/master/examples/js/WebGL.js) (() => {原创 2021-01-18 11:25:49 · 219 阅读 · 0 评论 -
每天进步一点点之jq底层
<div id="app" class="removeClass remainClass"> <button @click="toggle">toggle</button> </div> methods: { toggle() { this.dom.classList.toggle("toggle"); }, }, mounted() { this.dom = document.getElementB原创 2020-08-23 21:20:49 · 89 阅读 · 0 评论 -
js进阶
一 var User = { count: 1, getCount: function() { console.log('this',this) return this.count; } }; User.getCount()//1 var func = User.getCount;//var定义的变量挂在window下,属于window的变量 func()//this is undefined,window原创 2020-08-23 19:57:34 · 119 阅读 · 0 评论 -
非对称私钥解密
import JSEncrypt from "jsencrypt/bin/jsencrypt";let decrypt = new JSEncrypt(); let rsaPassWord = `BB6iosVbzZ3ocfHOSptJtqRPSYV0q7PcTFqQScY+XDaC+jPI8ONeYrDvntGcuWN4I2eBM0TRj43Y1/sezgrOGRqrp1EEIVwEsiuVBtOl0bsxMxxJKduLxRGSkI+xv1GLbXsTLn2Ymr1T2UTVHKve/o/k原创 2020-08-23 19:52:19 · 233 阅读 · 0 评论 -
每天进步一点点之js
let myStyle = document.getElementById("app").style; myStyle.height = "100px"; myStyle.width = "100px"; myStyle.border = "1px solid red"; var myP = document.createElement("p"); myP.id = "myp"; var node = document.createTextNode("段落"原创 2020-08-11 23:47:57 · 129 阅读 · 0 评论 -
高级js底层
创建,添加,移除节点var para = document.createElement("p");//createElement var node = document.createTextNode("这是一个新段落。");//createTextNode para.appendChild(node);//appendChild var element = document.getElementById("mydiv"); element.appendChild(par.原创 2020-08-04 00:10:35 · 153 阅读 · 0 评论 -
Object.defineProperty定义对象的属性
let person = {} Object.defineProperty(person,'name',{ value:'malinshu' }) console.log(person.name)//malinshu person.name = 'shu'//不可修改 console.log(p...原创 2020-03-28 12:06:07 · 192 阅读 · 0 评论 -
原型链深入理解、delete删除
函数就是原型的构造函数function Person(){//这个函数就是原型的构造函数 } Person.prototype.name = 'malinshu' console.log(Person.prototype.constructor == Person)//true let person1 = new Person...原创 2020-03-28 09:53:27 · 505 阅读 · 0 评论 -
js闭包的运用、作用域
让原本不能传参的函数成为可以传参function test(param){ return function(){ console.log(param) } } setInterval(test(1), 1000);//让原本不能传参的函数成为可以传参私有变量 ...原创 2020-03-28 09:13:01 · 128 阅读 · 0 评论 -
localStorage存对象取出来不是对象怎么办
存入之后值[object Object]的取出来又不能用obj.attr来获取值,解决方法如下:localStorage.setItem(‘logo’,JSON.stringify(res.logo))先转换为json字符串JSON.parse(localStorage.getItem(‘logo’))取出来再转为json对象这问题小程序和vue项目都一样...原创 2020-01-04 10:41:13 · 1612 阅读 · 0 评论 -
a标签调用接口下载文件
const a = document.createElement('a') document.body.appendChild(a); a.setAttribute('download', '') a.setAttribute('href', this.$baseURL + '/warehouse/export') a.setAttr...原创 2020-01-02 17:47:02 · 2560 阅读 · 0 评论 -
上传预览图片
<input type="file" id="file" name="file" ref="file"> let imgURL = URL.createObjectURL(this.$refs.file.files[0])//生成的图片路径为blob:http://192.168.0.10:8080/cdcf2f02-35e8...原创 2019-12-26 14:46:17 · 83 阅读 · 0 评论 -
ajax上传文件
<input type="file" name="file" @change="fileSel" ref="file" id="file">fileSel(e) { let form = new FormData(); form.append("file", this.$refs.file.files[0]); let config ...原创 2019-12-13 15:45:33 · 64 阅读 · 0 评论