boostrap4-按屏幕尺寸显示和隐藏
原文见 <!-- sm 及以下隐藏: 全部隐藏, md 及以上显示(block) --> <div class="d-none d-md-block"> hello bootstrap </div>js-邮箱正则
let reg = new RegExp("^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-z]{2,}$") reg.test('123456@qq.com')element-ui-一系列-then,-catch-事件转成-async-await
// message box async open() { const res = await this.$confirm('此操作将永久删除该文件, 是否继续?', '提示').catch(_ => { console.log('已取消, 结束') }) if (res !== 'confirm') { return } console.log(res, "已确认, 可以next") } 原文参见 csdnnuxt-部署并使用-nginx-作端口转发
代码上传 linux 服务器后, 注意 windows 下开发的 node-sass 包需要重新安装(npm rebuild node-sass), 打包 nuxt 项目 npm run build pm2 启动 nuxt start, 在项目根目录下 pm2 start node_modules/nuxt/bin/nuxt.js -- start 配置 nginx 文件 // 最简配置 server { listen 80; server_name www.nuxt-project.com; location / { proxy_pass http://127.0.0.1:3000; } } 部署时遇到一个问题, nuxt 代码里的 api 请求地址是本地的, 放到服务器也没改, 造成会返 500 部署也可参照 nuxt 官方部署文档element-ui-响应式布局-span-不能为0
<el-col :md="{span:8}" :sm="{span:0}" :xs="{span:0}"> .... </el-col > 会导致样式混乱, 达不到想要的隐藏效果, 可以用 .hidden-sm-and-down 类来实现nuxt-asyncData-多个接口异步
接口同步, 耗时长 async asyncData({$axios}){ let res1 = await $axios.get('...') let res2 = await $axios.get('...') return { res1: res1, res2: res2 } } 接口异步 async asyncData({$axios}){ let [res1, res2] = await Promise.all([ $axios.get('...'), $axios.get('...') ]} return { res1: res1, res2: res2 }页面重定向跳转
要求进入某个页面时直接跳转到另一个页面 之前都是在 script 中添加 window.location.href = 目标地址 今天 curl http://baidu.com 后发现一段代码 <html> <meta http-equiv="refresh" content="0;url=http://www.baidu.com/"> </html> 使用 <meta http-equiv="refresh" content="0;url=目标地址"> 也可以直接重定向到另一个网址搜索框中输入法弹出时,-按回车直接走了搜索
此时按下回车, 却到了搜索页面 解决办法, 把搜索事件的 按下 enter 事件改为 keydown.native.enterjs-对象深度复制
js 对象复制是地址传递, 而不是值传递, 可以使用如下方法进行``深度复制` deepClone(origin) { let target = {} for (var prop in origin) { if (origin.hasOwnProperty(prop)) { if (typeof (origin[prop]) == 'object' && origin[prop]) { target[prop] = Object.prototype.toString.call(prop) == '[object Array]' ? [] : {} arguments.callee(origin[prop], target[prop]) //递归调用 } else { target[prop] = origin[prop] //原始类型直接复制 } } } return target }nuxt-服务端操作-cookie
cookie-universal-nuxt, 见 npm You can use cookie-universal-nuxt to set, get and remove cookies in both client and server side nuxt apps
Recent Posts
Tags
- apache 4
- axios 1
- benchmark 1
- c 1
- canvas 1
- centos 3
- channel 1
- crontab 1
- css 2
- docker 4
- fail2ban 1
- frp 1
- gin 1
- github 1
- go 26
- goaccess 1
- goroutine 1
- http 1
- https 1
- jetbrains 1
- jquery 1
- js 2
- linux 20
- mermaid 1
- mysql 10
- nginx 3
- node 1
- php 43
- prisma 1
- react 8
- server 1
- ssh 2
- tarojs 1
- tcp/ip 1
- token 1
- ubuntu 1
- ufw 1
- unit-test 1
- vmware 1
- vscode 1
- vue 12
- yum 1
- 域名 3
- 安全 2
- 微信 3
- 算法 3