
js
追梦小狂魔
只要相信自己就没有什么不做不到
展开
-
eslint 不校验单个js文件
/* eslint-disable */一定是第一行加入原创 2022-04-03 20:33:23 · 1938 阅读 · 0 评论 -
js获取文件的后缀名
const h = file.name.substring(file.name.lastIndexOf('.') + 1)比如1.pdf得到pdf原创 2022-04-02 19:58:36 · 6468 阅读 · 0 评论 -
vue实现不同页面显示不同标题
在router的index.js加入metameta: { title: '首页' }在main.js加入路由守卫router.beforeEach((to, from, next) => { // to去哪 from 来自 if (to.meta.title) { document.title = to.meta.title } next()})原创 2022-03-31 10:17:20 · 793 阅读 · 0 评论 -
js数字三个加一个逗号
toThousands(num) { const result = []; let counter = 0 num = (num || 0).toString().split('') for (let i = num.length - 1; i >= 0; i--) { counter++ result.unshift(num[i]) if (!(counter % 3) && i !== 0) { .原创 2022-03-29 16:14:31 · 434 阅读 · 0 评论 -
vue pdf.js统计pdf的页数
参考链接作者原文展示了PDF,我只需要一部分功能<template> <div class="preview-pdf"> <h1>PDF页数为{{pdfPages}}</h1> <div :style="`margin:0 auto;width:${pdfWidth};`"> <canvas v-for="page in pdfPages" :key="page"原创 2022-03-28 17:06:13 · 4378 阅读 · 2 评论 -
error: Newline required at end of file but not found (eol-last) at vue
eslint要求太严格了,这里有了格式冲突问题,最后应该加一行空行,但是默认又会删除空行,导致反复报错禁用这个vscode的 JS-CSS-HTML Formatter原创 2022-03-21 10:43:13 · 1120 阅读 · 0 评论 -
npm切换源淘宝源的两种方法
npm install -g nrm nrm lsnrm use taobao原创 2022-03-19 11:59:10 · 1032 阅读 · 0 评论 -
jquery滑动到指定位置
var current = $("#div_a").offset().top; // alert(current) $("html,body").stop().animate({ scrollTop: current }, 300);300毫秒完成原创 2022-03-08 10:34:33 · 2514 阅读 · 0 评论 -
js下载文件
var xhr = new XMLHttpRequest(); xhr.open("GET", url, true); xhr.responseType = "blob"; xhr.onload = function() { var urlCreator = window.URL; var imageUrl = urlCreator.createObjectURL...原创 2022-02-25 16:35:31 · 528 阅读 · 0 评论 -
前端使用nodejs的包
先建立一个文件夹mkdir testcd test npm init安装nodejs需要的包npm install file-type在创建一个js文件,不需要写任何内容index.js然后打包browserify -r xxx index.js > bundle.js如果出现这个需要用管理员身份运行cmd...原创 2022-02-07 19:54:23 · 544 阅读 · 0 评论 -
js出现.endWith is not a function问题
把这一句加在开头就行了String.prototype.endWith = function(suffix) { return this.indexOf(suffix, this.length - suffix.length) !== -1; };原创 2021-12-02 09:08:52 · 3088 阅读 · 0 评论