个人笔记

js图片预览:

function viewPic(id, imgId) {
var reads = new FileReader();
f = document.getElementById(id).files[0];
if (f) {
reads.readAsDataURL(f);
reads.onload = function (e) {
document.getElementById(imgId).src = this.result;
$("#" + imgId).css("display", "block");
};
}
}

layui
function closeIframe() {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
window.parent.location.reload();
}
跨域:springboot配置

private CorsConfiguration buildConfig() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("*"); // 1允许任何域名使用
corsConfiguration.addAllowedHeader("*"); // 2允许任何头
corsConfiguration.addAllowedMethod("*"); // 3允许任何方法(post、get等)
return corsConfiguration;
}

@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", buildConfig()); // 4
return new CorsFilter(source);
}

posted on 2019-08-21 15:21  卖小女孩的小男孩  阅读(76)  评论(0)    收藏  举报