Buefy使用
Buefy安装
npm install buefy
引入Vue项目
不需要自定义样式
main.js
import Vue from 'vue'
import Buefy from 'buefy'
import 'buefy/dist/buefy.css'
Vue.use(Buefy)
需要自定义样式
npm install sass-loader -D
npm set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass
npm install node-sass -D
src/scss/doubucket.scss
@import "~bulma/sass/utilities/_all"; ...
Vue Mixins使用
被引用的Mixins
src/mixin/modeText.js
export default {
computed: {
modeText() {
if (this.mode === 'learning') {
return '学习模式'
} else if (this.mode === 'exercise') {
return '练习模式'
} else if (this.mode === 'test') {
return '测试模式'
} else {
return ''
}
}
...
MySQL字符集最佳实践
字符集的选择
建议使用utf8mb4,这是UTF-8的完整实现,字符最大长度为4字节,包含颜文字和生僻中文字。而utf8字符最大长度为3字节。
排序字符集选择
建议使用utf8mb4_unicode_ci,能够实现精确的排序,性能损耗不大。
简述CAP与BASE
CAP
Consistency 一致性、Availability 可用性、Partition tolerance 分区容错性。
分区容错性P是前提。分区是指集群中出现互相不可访问的区域,分区容错性是指当出现分区时,系统整体依然可以提供服务,至少不是全部停止服务。
当出现分区时,C一致性和A可用性存在矛盾,选择越高的一致性,则必然导致可用性的降低,反之亦然。
极端的CP系统,当分区出现时,接收数据更新请求的服务器无法将新数据同步到另一分区的服务器,此分区的服务器要么等待数据同步,全部停止提供服务。要么取消写入新数据,写服务不可用。
极端的AP系统,当分区出现时,接收数据更新请求的服务器先把自己的数据更新,然后继续提供服务,不等待其它任何服务器的数据同步。同一分区的其它服务器也许在...
浏览器缓存
浏览器缓存类型
本地缓存,也叫强缓存。使用本地缓存时,浏览器可以直接从本地的内存或磁盘中获取内容,不需要与服务器产生实际的交互
协商缓存,也叫弱缓存。使用协商缓存时,浏览器需要先向服务器验证缓存内容的有效性,如缓存内容还是最新的,则浏览器可以使用该缓存
浏览器缓存控制
HTTP 1.1风格
服务器在返回资源到浏览器时,通过在HTTP响应头增加Cache-Control属性控制浏览器缓存
例子
Cache-Control: max-age=31536000 开启浏览器缓存,缓存有效时间max-age,单位为秒。在缓存有效期间,命中本地缓存,不需要发送网络请求到服务器获取资源,而是直接取浏览器本地资源。缓存过期后,命中协商缓存,要通过服务器认证,确认缓存还是最新...
axios发送请求参数
GET方法
URL参数拼接
axios.get('api/login/oauth2/code/github?code=' + code + '&state=' + state, {
timeout: 5000,
}).then(successHandler).catch(failHandler)
config
axios.get('api/login/oauth2/code/github', {
params: {
code,
state
},
timeout: 5000
}).then(successHandler).catch(failHandler)
POST方法
POST方法接受的data参数对象默认以JSON格式传输...
Spring循环依赖解决方案
循环依赖bean的创建过程
假设需要创建两个bean,a和b,并出现循环依赖。这里a和b都应是单例的,注入方式为setter注入
@Component
public class A {
@Autowired
private B b;
}
@Component
public class B {
@Autowired
private A a;
}
假设Spring容器需要先创建a,则将会执行下列流程
依次检查一级缓存singletonObjects、二级缓存earlySingletonObjects、三级缓存singletonFactories。由于是第一次获取a,无法从缓存直接返回
实例化a对象
将可以获取a对象的单例工厂放进三...
Vue单文件组件基础结构
代码实例
<template>
<div></div>
</template>
<script>
import loginApi from '@/api/login'
import StartComponent from '@/components/StartComponent'
export default {
name: 'MyComponent',
components: {
StartComponent
},
data() {
return {
currentId: 1,
currentName: 'guest'
}
},
method...
Java项目.gitignore最佳实践
Java项目.gitignore配置例子
# Default ignored files
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/target/
HELP.md
!.m...
Git多账号配置
配置Git的SSH config文件,指定私钥
打开~/.ssh/config文件,如果没有则新建
Host github.com
IdentityFile ~/.ssh/id_ed25519_github
Host gitlab.yourdomain.com
IdentityFile ~/.ssh/id_ed25519_gitlab
验证是否可以通过SSH连接
ssh -T git@gitlab.yourdomain.com
ssh -T git@github.com
用户名和邮箱根据需要配置
git config --global --list
git config --global --unset user.name
git config --global -...
332 post articles, 34 pages.