周凯,个人博客

  • 前端
  • 嵌入式
  • 工具
  • 后端
  • 随笔
前端
前端

scss常用方法

新建comm.scss文件 @mixin flex($direction: row, $justify-content: center, $align-items: center) { display: flex; flex-direction: $direction; justify-content: $justify-content; align-items: $align-items; } 然后,在你的主Sass文件中,使用@include引入 flex .selector { @include flex(r…

2023年 7月 11日 0条评论 575点热度 0人点赞 周凯 阅读全文
react

nextjs export 静态页面时避免出现404

问题 当你写完多个页面,exoprt静态页面后,放在服务器上直接访问某个子页面**​**,发现直接访问给你返回了个404,你去查看目录结构,发现nextjs工具给你生成了register.html。而不是/register/index.html。自然会返回404 解决办法 官方文档也有提及 修改next.config.js 。添加 exportTrailingSlash: true module.exports = withLess({ exportTrailingSlash: true, // make /abo…

2023年 7月 7日 1条评论 1010点热度 0人点赞 周凯 阅读全文
vite

Vue2.7 + Vite + Eslint配置

在根目录下添加 .editorconfig 文件: # EditorConfig is awesome: https://EditorConfig.org # top-most EditorConfig file root = true [*] indent_style = space indent_size = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = false insert_final_newline = false 安装 es…

2023年 5月 29日 0条评论 1352点热度 0人点赞 周凯 阅读全文
javascript

获取浏览器中url参数的方式

字符串截取,通过url获取参数 function getUrl(url){    let arr = url.split('?');    let params = arr[1].split('&');    let obj = {};    for(let i=0;i<params.length;i++){        let param = params[i].split('=');        obj[param[0]] = par…

2023年 4月 23日 0条评论 763点热度 1人点赞 周凯 阅读全文
typescript

前端Logs简单封装

ts const Logs = { /** * 成功 * @param val * @param title */ success(val: any, title?: string) { console.log(`%c ${title || 'success'}: `, 'color: #67C23A; font-weight: bold', val); }, /** * 失败 * @param val * @param title */ error(val: any, ti…

2023年 4月 19日 0条评论 1063点热度 0人点赞 周凯 阅读全文
vue2

vue.config.js vue-cli5 配置路径别名@和跨域proxy

遇到的问题 我用vue-cli5创建一个vue3项目(vue-cli默认是webpack集成),想使用路径别名@和跨域proxy。于是我去网站上各种找,最后发现如下方法。 默认vue.config.js代码 const { defineConfig } = require('@vue/cli-service') module.exports = defineConfig({ transpileDependencies: true, lintOnSave: false }) 解决 删除defineConfig.直接在…

2023年 3月 15日 0条评论 832点热度 1人点赞 周凯 阅读全文
vite

Vite 配置代理 Proxy,避免跨域和重复编写url的问题

我们在编写前端项目的时候,经常会遇到跨域的问题,当我们访问后端 API 的 URL 路径时,只要域名、端口或访问协议(如 HTTP 和 HTTPS)有一项不同,就会被浏览器认定为跨域。另外我们也会经常重复编写后端的域名,例如 https://example.com/api/some_end_point,https://example.com/api/other_end_point,针对这两种情况,可以直接用同一个配置来解决,即代理配置。 不管是 Vite 还是 Webpack,这些打包工具都支持设置前端代理,它们能…

2023年 3月 8日 0条评论 1648点热度 1人点赞 周凯 阅读全文
javascript

使用blob 实现 js下载word、Excel等文件

把后端返回来的数据文本或者二进制流的数据,转换成字节,返回成一个新的blob对象,再去进行下载 代码示例 axios.get("xxx").then(res=>{ const blob = new Blob([res], { type: "application/msword;charset=utf-8" }); let url = window.URL.createObjectURL(blob); if (window.navigator.msSaveOrOpenBlob) { // 兼容IE10 navigat…

2023年 3月 8日 0条评论 784点热度 1人点赞 周凯 阅读全文
vue2

vue-cli3/4去除console

安装依赖 npm install babel-plugin-transform-remove-console -D 在babel.config.js中配置plugin,不需要引入插件 let plugin = [] if (process.env.NODE_ENV === 'production') { // 如果是生产环境 plugin.push([ 'transform-remove-console', { exclude: ['error', �…

2023年 3月 8日 0条评论 931点热度 0人点赞 周凯 阅读全文
前端

使用Iframe嵌入地址,X-Frame-Options 无法访问问题的解决方案

问题 正常部署应用后,将部署应用的地址嵌入到ifame中,页面显示拒绝了连接请求,提示报错如下 请求头中返回的时候携带了 x-frame-options Sameorigin 参考 MDN解释 X-Frame-Options - HTTP | MDN (mozilla.org) 解决 修改当前的请求地址nginx配置,对iframe引入的http://com.ityj.frame/xframe/hello,通过nginx过滤掉X-Frame-Options的配置 location / { #root html; #…

2023年 3月 1日 0条评论 1008点热度 0人点赞 周凯 阅读全文
12345…6
搜索
分类
归档

COPYRIGHT © 2022-现在 周凯,个人博客. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

蒙ICP备18004897号