vue watch 同时监听对象多个属性,调用同一个方法

比如说有个对象:

let form = {
    name: "xx",
    sex: "yy",
    type: "aa"
}

要求是修改name或者aa的时候,都调用 AABBCC 方法,但type修改的时候不能调用。
如果直接watch,那么肯定不能直接deep监听form对象了,因为type修改时不能调用。所以只能这样:

watch:{
    'form.name'(){
        this.AABBCC()
    },
    'form.sex'(){
        this.AABBCC()
    }
}

对象多的话,会感觉很难受,所以我们可以借用computed换换脑子:

computed:{
    formWatch: function(){
        let _arr = []
        _arr.push(this.form.name)
        _arr.push(this.form.sex)
        return _arr.join(",")
    }
},
watch:{
    formWatch(){
        this.AABBCC()
    }
}

这显然感觉舒服多了,哈哈

ERROR! The server quit without updating PID file (/usr/local/mysql/data/MacBook-Pro.local.pid). 重启MAC后碰到这个报错怎么办?

今天更新了系统,然后我重启电脑,在启动发现mysql起不来了。。。

报这么一个错:

ERROR! The server quit without updating PID file (/usr/local/mysql/data/Mac.local.pid).

网上找了很久解决方法,修改什么my.conf啥的,发现根本不适用,那个应该是用在服务器上的。
最后找到解决办法,超级简单,就是权限问题引起的,估计是更新了系统,把读写权限给刷了:

sudo chown -R _mysql:_mysql /usr/local/mysql/

修改权限后,启动成功

sudo /usr/local/MySQL/support-files/mysql.server start

Updating Homebrew… 一直卡住怎么处理?

brew install安装一个东西,然后突然 Updating Homebrew... 卡住了,之前一直公司网好像不卡,现在疫情在自己家,它居然能卡着完全不动。。。

那我就把它换个源吧~ ,换成 aliyun 的源。

替换 / 还原 brew.git 仓库地址

替换成阿里巴巴的 brew.git 仓库地址:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

=======================================================
还原为官方提供的 brew.git 仓库地址
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

替换 / 还原 homebrew-core.git 仓库地址

替换成阿里巴巴的 homebrew-core.git 仓库地址:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

=======================================================
还原为官方提供的 homebrew-core.git 仓库地址
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git

替换 / 还原 homebrew-bottles 访问地址

这个步骤跟你的 macOS 系统使用的 shell 版本有关系

所以,先来查看当前使用的 shell 版本

echo $SHELL

  • 如果你的输出结果是 /bin/zsh,参考?的 zsh 终端操作方式
  • 如果你的输出结果是 /bin/bash,参考?的 bash 终端操作方式

zsh 终端操作方式

替换成阿里巴巴的 homebrew-bottles 访问地址:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

=======================================================

还原为官方提供的 homebrew-bottles 访问地址

vi ~/.zshrc

然后,删除 HOMEBREW_BOTTLE_DOMAIN 这一行配置

source ~/.zshrc

bash 终端操作方式

替换 homebrew-bottles 访问 URL:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

=======================================================

还原为官方提供的 homebrew-bottles 访问地址

vi ~/.bash_profile

然后,删除 HOMEBREW_BOTTLE_DOMAIN 这一行配置

source ~/.bash_profile

转载:JS二维数组排列组合,列出所有结果

最近做一个项目,碰到一个根据数组,列出所有相关排列组合的内容的需求。
百度搜出如下解决方案,非常精简强悍,比自己罗里吧嗦写了一堆的好太多了,记录分享。

let array1 = [
    ['红', '绿', '蓝'],
    ['A', 'B', 'C'],
    ['S', 'M', 'L'],
]

let array2 = [
    ['红', '蓝'],
    ['A', 'B', 'C'],
    ['S'],
]

let array3 = [
    ['红', '绿', '蓝'],
]

function calc(transArr) {
    let resultArr = [];
    function get(array, index, val) {
        if(!array[index]) {
            resultArr.push(val);
            return;
        };

        array[index].forEach((v, i) => {
            get(array, index + 1, index === 0 ? [v] : [...val, v])
        })
    }
    get(transArr, 0);
    return resultArr;
}

console.log(calc(array1));
console.log(calc(array2));
console.log(calc(array3));

原文链接:https://blog.csdn.net/qq1073830130/article/details/101017851

禁止chrome谷歌浏览器表单自动填充,新版chrome的autocomplete设置无效的处理方法

网上最常见的方式,是设置autocomplete='off',但这种方式已经无效啦。

还有种方式是:

<input type="text"  style="display: none;" autocomplete = "off"/>
<input type="password"  style="display: none;" autocomplete = "off"/>

每个表单都要配置,特别麻烦。而且最近也失效了。

经过很长时间测试,我发现可以在vue、react、angular的情况下,可以用一个一劳永逸的方式,就是再入口文件,如vue的App.vue文件下,写这么一段:

    <!-- 防止chrome自动填充 -->
    <div style="position:absolute;top:-999999px">
      <input type="text" />
      <input type="password" />
    </div>

然后你页面上所有的表单都不会被填充啦,超赞的

cannot load such file — active_support/core_ext/object/blank 报错处理(brew update原因)

手贱跑了下brew update,结果一直没成功,然后打开终端报这个错。

Traceback (most recent call last):
    3: from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `<main>'
    2: from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `require_relative'
    1: from /usr/local/Homebrew/Library/Homebrew/global.rb:12:in `<top (required)>'
/usr/local/Homebrew/Library/Homebrew/global.rb:12:in `require': cannot load such file -- active_support/core_ext/object/blank (LoadError)

网上学习后,发现解决方法也很简单:
执行命令:brew update-reset,重新设置下brew的配置。

记录学习~

Authentication plugin ‘caching_sha2_password’ cannot be loaded: 客户端工具连接MySQL报错处理方式

最近在用Navicat连接新安装的MySQL<8.0.17>数据库时会出现Authentication plugin 'caching_sha2_password' cannot be loaded的错误。

出现这个原因是mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password, 解决问题方法有两种,一种是升级navicat驱动,一种是把mysql用户登录密码加密规则还原成mysql_native_password.

具体代码及操作如下:

# 连接mysql
zhujin@zhujindeMacBook-Pro ~ % mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.17 MySQL Community Server - GPL
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# 开始执行代码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; 
Query OK, 0 rows affected (0.01 sec)
# 设置新的加密规则下的密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'zj123456';
Query OK, 0 rows affected (0.01 sec)
# 刷新规则
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

然后就顺利连上了。

MacOS zsh: command not found: mysql 解决方案

最近重新安装了Mac上的MySQL,突然发现从终端连接不上,command not found: mysql。

zhujin@zhujindeMacBook-Pro ~ % mysql
zsh: command not found: mysql

很明显我们一眼就知道,这属于mysql命令没有链接上而已,很好处理。
直接通过alias设置别名就行了, 常见的设置别名的文件如下。

~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该文件被读取.(每个用户都有一个.bashrc文件,在用户目录下)

~/.bash_profile:每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.

~/.zshrc:zsh配置文件,每次打开新的shell时,该文件被读取.如果没有,可以自行创建。

所以,我们可以在~/.bashrc 或者 ~/.zshrc中写下别名,首先看看mysql安装地址。

我没有修改过,所以默认 /usr/local/mysql,所以,在~/.bashrc 或者 ~/.zshrc任一文件中添加:

alias mysql=/usr/local/mysql/bin/mysql

然后source一下,试试效果:

# 编辑.zshrc添加alias语句
zhujin@zhujindeMacBook-Pro ~ % vim .zshrc
# 运行一次.zshrc文件
zhujin@zhujindeMacBook-Pro ~ % source .zshrc 
# 尝试连接mysql
zhujin@zhujindeMacBook-Pro ~ % mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.17 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# 完美
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

ubuntu 新建用户并设置sudo权限

首先使用adduser添加用户

root@iZbp121mi6a5espq574bonZ:~# adduser test
Adding user `test' ...
Adding new group `test' (1001) ...
Adding new user `test' (1001) with group `test' ...
Creating home directory `/home/test' ...
Copying files from `/etc/skel' ...
# 登录密码
Enter new UNIX password: 
# 再次输入密码
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for test
Enter the new value, or press ENTER for the default
# 一些有的没的各种信息,我一般是不写的
        Full Name []: 
        Room Number []: 
        Work Phone []: 
        Home Phone []: 
        Other []: 
Is the information correct? [Y/n] 

这样就相当于已经建立完成了,id <用户名>看一下

root@iZbp121mi6a5espq574bonZ:~# id test
uid=1001(test) gid=1001(test) groups=1001(test)

可以看到,用户已经创建成功了,接下来把他放到sudo组

root@iZbp121mi6a5espq574bonZ:~# adduser test sudo
Adding user `test' to group `sudo' ...
Adding user test to group sudo
Done.

接下来看一下id <用户名>,会发现多了个sudo组,那么这个用户就已经有sudo权限了

root@iZbp121mi6a5espq574bonZ:~# id test
uid=1001(test) gid=1001(test) groups=1001(test),27(sudo)

大功告成,谢谢惠顾。

macOS Catalina 下干净彻底地卸载 MySQL并重装MySQL

最近系统升级了macOS Catalina,发现好多软件都不能用了,最主要mysql也不能用了,因为网上找了半天没怎么找到特别方便的处理方案,之前的版本也比较低,所以准备卸载了,然后重新安装。

------ 卸载 ------

卸载的话比较粗糙,直接删除了所有相关的文件与文件夹。

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*

------安装------
从官方网站下下载最新的mysql(需要科学上网):
https://downloads.mysql.com/archives/community/
8.0.17的下载地址是,如果没有翻墙工具,可以尝试直接用迅雷下:
https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.17-macos10.14-x86_64.dmg
下载完成后,双击无脑安装。