继开 | 博客

热爱生活,努力学习,实现自己的价值


  • 短诗的序

  • 迷途自渡

  • 寒星三两

  • 林深见鹿

  • 记昨日书

  • 顾探往昔

Intelx722不支持百兆网络

发表于 2021-11-27
字数统计: 78 字 | 阅读时长 ≈ 1 min

intelx722不支持百兆网络

一辈子很短,努力的做好两件事就好;
第一件事是热爱生活,好好的去爱身边的人;
第二件事是努力学习,在工作中取得不一样的成绩,实现自己的价值,而不是仅仅为了赚钱;

Linux+Windows 解决从GitHub下载资源速度慢的方法

发表于 2021-11-17
字数统计: 255 字 | 阅读时长 ≈ 1 min

步骤一、vi /etc/hosts,添加下面三句

1
2
3
4
140.82.113.4  github.com
199.232.69.194 github.global.ssl.fastly.net
140.82.113.10 codeload.github.com
185.199.108.133 raw.githubusercontent.com

//上面的网址IP也许会发生变化,这样就要修改ip,但目前来看IP还是这个
需要查看IP对不对的自行度娘就可以了

重启网络

1
service network restart

顺便说一下:Windows的也是一样的,修改hosts文件,将上面三句添加进去
在目录 “C:\Windows\System32\drivers\etc”
然后运行cmd,刷新dns,执行ipconfig /flushdns

1
ipconfig /flushdns

配置完成,重新下载速度就正常了!

GitHub的网址IP可能会变化,可以用下面的网址查
https://www.ipaddress.com/

一辈子很短,努力的做好两件事就好;
第一件事是热爱生活,好好的去爱身边的人;
第二件事是努力学习,在工作中取得不一样的成绩,实现自己的价值,而不是仅仅为了赚钱;

Js 中Sort按照固定数组元素排序

发表于 2021-11-07
字数统计: 191 字 | 阅读时长 ≈ 1 min

假如有个数组testArray 如下:

1
var testArray = ["test4","test2", "test1", "test3"];

如果让其按照数组standardArray的固定元素来排序,数组standardArray如下:

1
var standardArray = ["test1", "test2", "test3", "test4","test5"];

期望得到的结果是:

1
var testArray =  ["test1", "test2", "test3", "test4"];

则方法如下:

1
2
3
4
5
6
7
8
9
testArray.sort(function (a, b) {
if (standardArray.indexOf(a)< standardArray.indexOf(b)){
return -1;
}
if (standardArray.indexOf(a)> standardArray.indexOf(b)){
return 1;
}
return 0;
});

sort参数说明:

若 a 小于 b,在排序后的数组中 a 应该出现在 b 之前,则返回一个小于 0 的值。
若 a 等于 b,则返回 0。
若 a 大于 b,则返回一个大于 0 的值。
在本例中,先确定testArray的每个元素在standardArray的位置。

var fruits = [“test4”,”test2”, “test1”, “test3”];

对应为 4,2,1,3

Sqlserver截取字符串拼接

发表于 2021-11-03
字数统计: 432 字 | 阅读时长 ≈ 2 min

去除括号及括号内内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

-->>测试数据
create table tb(col varchar(50))
insert into tb values('重庆唯远实业有限公司(2009年01月05日)')
insert into tb values('江苏苏美达船舶工程有限公司(2009年01月05日)')
insert into tb values('上海启门机电有限公司(2009年01月04日)')
insert into tb values('小洋人生物乳业集团有限公司(2009年01月04日)')
insert into tb values('沈阳鼎冷机电设备有限公司(2009年01月04日)')
insert into tb values('嘉柏(中国)国际货运代理有限公司(2008年12月31日)')
insert into tb values('广州宝洁有限公司(2008年12月31日)')
insert into tb values('烟台华科食品有限公司(2008年12月31日)')
insert into tb values('艾来得机械(上海)有限公司(2008年12月31日)')
insert into tb values('上海晓舟船舶配件有限公司(2008年12月31日)')
insert into tb values('上海力弘包装器材有限公司(2008年12月31日)')
--查询
select reverse(stuff(reverse(col), 1, charindex('(', reverse(col)), '')) from tb
--结果
/*

name
----------------------------------------------
重庆唯远实业有限公司
江苏苏美达船舶工程有限公司
上海启门机电有限公司
小洋人生物乳业集团有限公司
沈阳鼎冷机电设备有限公司
嘉柏(中国)国际货运代理有限公司
广州宝洁有限公司
烟台华科食品有限公司
艾来得机械(上海)有限公司
上海晓舟船舶配件有限公司
上海力弘包装器材有限公司



update tb
set col = reverse(stuff(reverse(col), 1, charindex('(', reverse(col)), ''))
select * from tb

drop table tb

Sqlserver备份数据表

发表于 2021-11-01
字数统计: 426 字 | 阅读时长 ≈ 2 min

快速备份表 saleDetail

使用select into 可以快速创建表并将表数据同时插入新建表中

1
2

select * into [saleDetail_20181012] from [saleDetail]

备份表数据还原,使用insert into 插入数据

1
2
insert into [saleDetail] 
select * from [saleDetail_20181012]

sqlserver 数据插入,若存在则更新,若没有则进行插入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

MERGE INTO merge_target target
USING (SELECT B.name,B.age,B.target_id FROM merge_source B) source
ON (target.id=source.target_id)
WHEN MATCHED THEN
UPDATE
SET target.name = source.name,
target.age = source.age
WHEN NOT MATCHED THEN
INSERT(target.name,target.age) VALUES (source.name,source.age);

```
注意,无论是merge_target中的id 还是 merge_source 中的id,单独查询,都不允许有重复的数据,若有重复数据,则会报错无法执行


##### sqlserver 数据插入,若存在则更新,若没有则进行插入,若目标表中有,来源表中没有则删除的sql写法

merge into 目标表 a
using 源表 b
on a.条件字段1=b.条件字段1 and a.条件字段2=b.条件字段2 …
when matched update set a.字段1=b.字段1,
a.字段2=b.字段2
when not matched insert values (b.字段1,b.字段2)
when not matched by source
then delete

1
例子:

create table targetTable(ID INT primary key identity(1,1),[name] varchar(50),age int)
create table sourceTable(ID INT primary key identity(1,1),[name] varchar(50),age int)
insert into targetTable([name],age) values(‘大卫’,40)

merge into targetTable as t
using sourceTable as S on t.ID=s.ID
when matched –更新 目标表中有ID,则更新
then update set t.[name]=S.[name]
when not matched –添加 目标表中没有ID,在原表中有,则插入相关数据
then insert values (s.[name],s.age)
when not matched by source –目标表存在,源表不存在,则删除
then delete;

```

Ant Design Vue customRow 不起作用

发表于 2021-10-27
字数统计: 344 字 | 阅读时长 ≈ 2 min

ant design vue customRow 不起作用

ant design vue 网站中的实例
https://www.antdv.com/components/table-cn/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<Table
customRow={(record) => {
return {
props: {
xxx... //属性
},
on: { // 事件
click: (event) => {}, // 点击行
dblclick: (event) => {},
contextmenu: (event) => {},
mouseenter: (event) => {}, // 鼠标移入行
mouseleave: (event) => {}
},

};
)}
customHeaderRow={(column) => {
return {
on: {
click: () => {}, // 点击表头行
}
};
)}
/>

线上网友一般使用的方式(还是不生效,或许因为vue版本不同,或者其他环境问题)

html代码:customRow绑定一个click方法,名字自己可以随便起

1
2
3
4
<a-table
:columns="columns"
:data-source="data"
:customRow='click'>

js代码:

1
2
3
4
5
6
7
8
9
10
11
methods: {
click(record, index) {
return {
on: {
dblclick: () => {
console.log(record);
}
}
}
}
}

​ 在js中的methods中创建方法click(record, index)。record与index 分别是该行的数据(可以获取到放在data-source中的所有属性,即使没有在表格中呈现出来的也可以获取到)和该行数据在表格中的下标。

​ 通过上面的写法,我可以在双击表格某一行的时候,打印出这一行所绑定的data的全部内容。

实际项目使用

1
2
3
4
5
6
<a-table
:columns="columns"
:data-source="data"
:customRow='click'>

```

methods: {
click:function(row,rowIndex){
const thisSelf = this;
return {
onClick: () => {
console.log(row, rowIndex)
if(row.btyAccountingSubjectCode ==”1012”||row.btyAccountingSubjectCode ==”1131”||row.btyAccountingSubjectCode ==”2121”){
thisSelf.openBtyAssistAccountingBalanceInit(row);
}
}
};
/**

  • 打开点击详情界面
    */
    openBtyAssistAccountingBalanceInit(row) {
    this.showBtyAssistAccountingBalanceInitParam = row;
    this.showBtyAssistAccountingBalanceInit = true;
    },
    }

```

Vue的iframe嵌套问题处理

发表于 2021-10-19
字数统计: 895 字 | 阅读时长 ≈ 4 min

vue嵌套iframe一系列问题

最近在项目中遇到一个需求需要在一个项目中直接引用另一个项目,尝试各种情况无果后选择了iframe。现将调用过程中遇到的问题做一个分享。

router.go()的使用
  此情况主要适用于更改iframe中src值以后导致的路由跳转混乱。

  详细描述:当多次更改iframe->src属性后,调用router.go(-1),不能实现路由后退上一级,而是将iframe当作一个窗口文档,调用了该窗口文档的window.history.go(-1),并未更改父级项目的路由后退功能。

  解决办法:

  不通过改变iframe->src属性值去访问具体内容,采用window.location.replace(url)更改iframe将访问的内容,具体代码如下:
A.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<template>
<iframe ref="iframe" scrolling="auto" width="100%" height="100%" frameborder="0" ></iframe>
</template>
<script>
export default {
name: 'ComponentsName',
data() {
return {
url: ''
}
},
watch: {
url(val) {
if (val) {
this.$refs.iframe.contentWindow.location.replace(val)
}
}
}
}
</script>

注意ref=”iframe” 中iframe,的名字若在多个页面情况下,建议用不同的名称,不然打包之后会报错
this.$refs.iframe.contentWindow.location.replace(val) 同样也需要修改

通信(父页面和子页面相互通信)

  两个项目之间相互通信,涉及到跨域问题,子页面不能直接调用父页面的方法,父页面同样不能调用子页面的方法。

  错误详情:Error in created hook: “SecurityError: Blocked a frame with origin “http://*” from accessing a cross-origin frame.”

  解决办法: postMessage

  window.postMessage() 方法可以安全地实现跨源通信。该方法被调用时,会在所有页面脚本执行完毕之后向目标窗口派发一个MessageEvent消息。代码如下:

index.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<html>
<head>
<title>Post Message</title>
</head>
<body>
<div>
<div id="color">Frame Color</div>
</div>
<div>
<iframe id="child" width="50%" src="http://172.16.110.188/test.html" height="50vw" scrolling="auto" frameborder="0"></iframe>
</div>
<script type="text/javascript">
window.onload=function(){
document.getElementById('child').contentWindow.postMessage('getcolor','http://172.16.110.188');
}
window.addEventListener('message',function(e){
var color=e.data;
document.getElementById('color').style.backgroundColor=color;
},false);
</script>
</body>
</html>

test.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!doctype html>
<html>
<head>
<style type="text/css">
html,body{
height:100%;
margin:0px;
}
#container{
widht:100%;
height:100%;
background-color:rgb(204, 102, 0);
}
</style>
</head>
<body style="height:100%;">
<div id="container" onclick="changeColor();">
click to change color
</div>
<script type="text/javascript">
var container=document.getElementById('container');
window.addEventListener('message',function(e){
if(e.source!=window.parent) return;
var color=container.style.backgroundColor;
window.parent.postMessage(color,'*');
},false);
function changeColor () {
var color=container.style.backgroundColor;
if(color=='rgb(204, 102, 0)'){
color='rgb(204, 204, 0)';
}else{
color='rgb(204,102,0)';
}
container.style.backgroundColor=color;
window.parent.postMessage(color,'*');
}
</script>
</body>
</html>

上面的例子实现了两个不同域的页面之间的通信。但由于我们此处用的是动态更改iframe.contentWindow.location来访问的内容,如果此处父页面要向子页面发起通信需要在iframe中页面加载完毕以后,不然子页面无法获取到通信数据。

应用场景
子页面需要调用父页面的方法或则使用父页面的数据时候,我们可以在子页面向父页面发起通信,让父页面调用该方法,或让父页面将数据传输过来。

注意事项
  postMessage支持对象传递,但不是所有浏览器都支持对象传递,在使用中还是使用字符串传值更好。

Nginx Nginx[warn]:an Upstream Response Is Buffered to a Temporary

发表于 2021-10-18
字数统计: 237 字 | 阅读时长 ≈ 1 min

1.nginx 报错

1
[warn] 19#19: *23 an upstream response is buffered to a temporary file /var/

2.解决

在nginx.conf 的http 里加入如下一段得到解决

1
2
3
4
fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;

另,如果nginx以proxy模式运行,则需更改上面一段为如下内容:

1
2
3
4
proxy_buffer_size 128k;
proxy_buffers 8 128k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;

注意:很多网上教程 fastcgi_buffers 8 128k;忘记加k ,这个会造成 [emerg] 1#1: “fastcgi_busy_buffers_size” must be less than the size of all “fastcgi_buffers”

完整nginx.conf配置如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# nginx.conf 例:
user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

fastcgi_buffer_size 128k;
fastcgi_buffers 8 128;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;

include /etc/nginx/conf.d/*.conf;
}

1…171819…38

继开

一辈子很短,努力的做好两件事就好:第一件事是热爱生活,好好的去爱身边的人;第二件事是努力学习,在工作中取得不一样的成绩,实现自己的价值,而不是仅仅为了赚钱。

303 日志
171 标签
RSS
gitee E-Mail
0%
鲁ICP备18007712号
© 2025 继开 | 站点字数统计: 262.2k
博客使用 Hexo 搭建
|
主题 — NexT.Mist v5.1.4
人访问 次查看