找到了就很简单了
onclick=”window.event.cancelBubble=true”
onclick=”event.stopPropagation();”
(1)stopPropagation符合W3C标准,适用于谷歌、火狐等浏览器,不支持IE
(2)cancelBubble方法不符合W3C标准,说是IE的,但是我谷歌上也可以用。
找到了就很简单了
onclick=”window.event.cancelBubble=true”
onclick=”event.stopPropagation();”
(1)stopPropagation符合W3C标准,适用于谷歌、火狐等浏览器,不支持IE
(2)cancelBubble方法不符合W3C标准,说是IE的,但是我谷歌上也可以用。
Execution failed for task ‘:app:mergeDexDebug’.
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate
> There was a failure while executing work items
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
* Try:
> Run with –stacktrace option to get the stack trace.
> Run with –info or –debug option to get more log output.
> Run with –scan to get full insights.
解决方法如下:
应用内级别build.gradle添加:
android { defaultConfig { ... multiDexEnabled true } } dependencies { implementation 'com.android.support:multidex:1.0.3' }
突然想到回顾docker创建自己常用镜像,做个记录。
环境为windows11、docker desktop,复制以下内容保存成对应文件
1.Dockerfile.ubuntu
# 指定基础镜像 FROM ubuntu # 镜像维护者作者 MAINTAINER Netpc.com.cn-ken # 环境变量 ENV MYPATH /usr/local # 工作路径,容器创建后,终端默认进入的工作目录,或者理解为落脚点 WORKDIR $MYPATH # 构成镜像时,执行的命令 # 从Dockerfile到images的过程中会执行的命令 # 备份原镜像软件源 RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak # 更改镜像为阿里镜像源 RUN echo "deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse" >> /etc/apt/sources.list RUN echo "deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse" >> /etc/apt/sources.list RUN echo "deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse" >> /etc/apt/sources.list RUN echo "deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse" >> /etc/apt/sources.list RUN echo "deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" >> /etc/apt/sources.list RUN apt-get update RUN apt-get install -y vim RUN apt-get install -y net-tools RUN apt-get install -y iputils-ping RUN apt-get install -y php7.4 php7.4-fpm php7.4-gd php7.4-mbstring php7.4-pdo php7.4-curl php7.4-mysql php7.4-mysqli php7.4-json php7.4-mbstring php7.4-xml RUN apt-get install -y nginx RUN apt-get install -y mysql-server mysql-client RUN usermod -d /var/lib/mysql/ mysql # 暴露端口 EXPOSE 80 EXPOSE 443 EXPOSE 3306 # 将宿主机的文件复制到镜像中 ADD mysql.sh /mysql.sh RUN chmod 777 /mysql.sh && /mysql.sh RUN rm -rf /mysql.sh # 将脚本复制到容器中 ADD a.php /var/www/html/ ADD start.sh /usr/local/bin/ ADD default /etc/nginx/sites-available/default # 设置脚本可执行权限 RUN chmod +x /usr/local/bin/start.sh # 在容器启动时执行脚本 CMD ["/usr/local/bin/start.sh"]
2.mysql.sh #启动mysql,修改默认账号信息
#!/bin/sh service mysql start mysql -uroot -e "use mysql;update user set Host='%' where User='root';flush privileges;ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';flush privileges;" echo 'bind-address = 0.0.0.0' >> /etc/mysql/mysql.conf.d/mysqld.cnf
3.default #为了替换原有的启动php
server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } # pass PHP scripts to FastCGI server # location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; } }
4.start.sh
#!/bin/sh service php7.4-fpm start service mysql start nginx -g "daemon off;" #不这样可能容器运行后会自动关闭
5.生成镜像命令:docker build -f Dockerfile.ubuntu -t ‘ubuntu-netpc’ .
6.docker run 映射到对应/var/www/html目录,就能把php放进去运行,映射端口3306就能直接访问容器内的mysql了。
上图
1.我已经在windows11安装好docker desktop了,还没的要先安装。
根据官方教程下载安装docker desktop执行文件.exe,可以参考文章
2.终端直接运行以下命令:
2.1创建mysql
docker run -d -p 3307:3306 –name mysql5.7.23 –privileged=true -v D:\docker\mysql-5.7.23\conf.d:/etc/mysql/conf.d -v D:\docker\mysql-5.7.23\logs:/var/log/mysql -v D:\docker\mysql-5.7.23\data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7.23
2.2创建php
docker run -p 9003:9000 –name php7.4 -v D:\docker\nginx-1.21.5\html:/usr/share/nginx/html –link mysql5.7.23:docker-mysql -d php:7.4-fpm
2.3创建nginx
docker run –name nginx1.21.5new -p 8080:80 -p 8081-8089:8081-8089-v D:\docker\nginx-1.21.5\html:/usr/share/nginx/html:ro -v D:\docker\nginx-1.21.5\conf:/etc/nginx:ro –link php7.4:localhost -d nginx
说明:
3.nginx配置文件D:\docker\nginx-1.21.5\conf\conf.d\default.conf
server { listen 80; listen [::]:80; server_name localhost; root /usr/share/nginx/html; index index.html index.htm index.php; location / { try_files $uri $uri/ /index.php$is_args$args; autoindex on; } location ~ \.php$ { add_header X-debug-message "A php file was used $document_root" always; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; fastcgi_pass localhost:9000; } }
说明:
3.1localhost:9000 表示 php-fpm 服务的访问路径, 已经通过link参数绑定了容器网络互通。
3.2/usr/share/nginx/html是nginx和php经docker映射变成本地路径D:\docker\nginx-1.21.5\html,都放一起就可以直接通过设置root参数,使用$document_root来指定SCRIPT_FILENAME的php文件路径,不然一不小心就找不到php文件出现404
4.最后都跑起来,放个phpmyadmin记得修改config.inc.php参数为上面起的别名,在容器内直接能访问到。
$cfg[‘Servers’][$i][‘host’] = ‘docker-mysql’;
docker里应该不能用locaohost,不然提示会mysqli_real_connect(): (HY000/2002): No such file or directory,用本地系统会去找mysql.stock,php容器里又不和MySQL一起,所以。。。
5.调试容器内通讯缺少工具的时候就执行下面几个常用命令安装下
apt update
apt install net-tools // 查看ip
apt install telnet //验证端口
apt install iputils-ping //ping
在windows或linux下不重新创建新的容器,直接修改原docker容器挂载盘或文件,IP映射端口等信息。
过程都是一样,停止docker服务,修改配置文件,启动docker。
windows下修改docker配置
运行环境windwos11、wsl2、ubuntu、Docker Desktop
1、确保服务里停掉docker容器和docker服务进程
2.在文件资源管理器里找到\\wsl.localhost\docker-desktop-data\data\docker\containers文件夹,对应着你实际容器的ID进入,找到config.v2.json和hostconfig.json,看名字就知道是josn格式了,内容很简单,先备份再修改,然后保存。
3.重新启动Docker Desktop即可。
linux下修改docker配置
和windows一样,先停止docker服务,接着在/var/lib/docker/containers/路径下找到对应容器ID目录进入,修改config.v2.json和hostconfig.json,保存,重启docker服务。
vue:@vue/cli 5.0.8
npm:8.1.0
node:v16.13.0
Vue CLI v5.0.8
? Please pick a preset:
vue3 ([Vue 3] dart-sass, babel, router, eslint) // 保存过自定义默认选项
Default ([Vue 3] babel, eslint)//默认(安装bable、eslint)
Default ([Vue 2] babel, eslint)//默认(安装bable、eslint)
> Manually select features //自定义
Vue CLI v5.0.8
? Please pick a preset: Manually select features
? Check the features needed for your project: (Press <space> to select, <a> to toggle all, <i> to invert selection, and
<enter> to proceed)
>(*) Babel //是一个 JavaScript 编译器ES6先后兼容ES5
( ) TypeScript // 微软开发的一个开源的编程语言,在JS的基础上构建而成超集
( ) Progressive Web App (PWA) Support // 渐进式Web应用
( ) Router // 路由
( ) Vuex // 状态管理库
( ) CSS Pre-processors // CSS预处理
(*) Linter / Formatter // 规范代码检查工具
( ) Unit Testing // 测试
( ) E2E Testing // 测试
Vue CLI v5.0.8
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, Vuex, CSS Pre-processors, Linter
2.3.1选择vue版本
? Choose a version of Vue.js that you want to start the project with (Use arrow keys)
> 3.x
2.x
2.3.2选择是否使用history历史模式的路由
? Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n)
2.3.3选择CSS预处理器
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): (Use arrow keys)
> Sass/SCSS (with dart-sass)
Less
Stylus
2.3.4选择哪个自动化代码格式化检测
? Pick a linter / formatter config: (Use arrow keys)
ESLint with error prevention only
ESLint + Airbnb config
ESLint + Standard config
> ESLint + Prettier
2.3.5选择什么时候进行语法检查
? Pick additional lint features: (Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed)
>(*) Lint on save // 语法检查配置文件保存时检查
( ) Lint and fix on commit // 文件提交时检查
2.3.6配置文件的存放位置(推荐独立放置配置文件)
? Where do you prefer placing config for Babel, ESLint, etc.? (Use arrow keys)
> In dedicated config files // 独立配置文件
In package.json // 放package.json里
2.3.6 是否保存以上设置(选择yes的话下次就可以直接使用刚才的配置了)
? Save this as a preset for future projects? (y/N)
Vue CLI v5.0.8
✨ Creating project in D:\www\test\test.
🗃 Initializing git repository…
⚙️ Installing CLI plugins. This might take a while…
added 861 packages in 3m
🚀 Invoking generators…
📦 Installing additional dependencies…
added 113 packages in 2m
⚓ Running completion hooks…
📄 Generating README.md…
🎉 Successfully created project test.
👉 Get started with the following commands:
$ cd test
$ npm run serve
在windows7上是必须用node14才能正常创建vue3,刚开始很多网上还写着@vue/cli3.X结果创建出来的实际是vue2.6,根据查看package.json文件查看能知道实际使用的vue版本
"dependencies": { "core-js": "^3.8.3", "vue": "^3.2.13", "vue-router": "^4.0.3", "vuex": "^4.0.0" },
最后是成功的,但是最高只能到nodejs14.17.6,不然会有dll动态链接库接口错误提示:无法定位程序输入点 getHostNameW 于动态链接库 WS2_32.dll
1、先下载windows7最后一个正常安装node-v13.4.0版本,下面地址
https://registry.npmmirror.com/-/binary/node/v13.4.0/node-v13.4.0-x64.msi
2、上面安装好后,下载下载的解压覆盖
https://registry.npmmirror.com/-/binary/node/v14.17.6/node-v14.17.6-win-x64.zip
3、打开cmd输入set NODE_SKIP_PLATFORM_CHECK=1,忽略版本检测
接着node -v看版本
以上都是镜像下载地址,官网不知为啥打不开
接着安装npm install-g @vue/cli,查看vue -V
@vue/cli 5.0.8
查看npm -v
8.13.2
执行vue create test
就可以选择创建vue3或vue2了
环境centos7,目前项目需要用到分布式,Elasticsearch直接做单机版,需要配置副本分片为0,让它不要去同步即可,不然状态会变成yellow,正常是green。
Elasticsearch
安装环境:yum install java-1.8.0-openjdk* -y
下载:wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.4.tar.gz
解压:tar -zxvf ./elasticsearch-6.8.4.tar.gz
root下不能跑,添加用户:useradd elasticsearch
设置目录所属:chown -R elasticsearch.elasticsearch ./elasticsearch-6.8.4
切换用户:su elasticsearch
启动:./bin/elasticsearch -d
停止:./bin/elasticsearch stop
配置文件:config/elasticsearch.yml
network.host: 127.0.0.1
http.port: 9200
kibana官网
https://www.elastic.co/cn/downloads/past-releases/kibana-6-8-23
下载:wget https://artifacts.elastic.co/downloads/kibana/kibana-6.8.23-linux-x86_64.tar.gz
解压:tar -zxvf kibana-6.8.23-linux-x86_64.tar.gz
root下不能跑,添加用户:useradd kibana
设置目录所属: chown -R kibana.kibana ./kibana-6.8.23-linux-x86_64
切换用户:su kibana
启动:./bin/kibana
配置文件:config/kibana.yml
server.port: 9800
server.host: “172.27.126.154”
elasticsearch.hosts: [“http://127.0.0.1:9200”]
kibana.index: “.kibana”
i18n.locale: “zh-CN”
Kibana报错:版本对应不上
FATAL ProductNotSupportedError: The client noticed that the server is not Elasticsearch and we do not support this unknown product.
Unable to retrieve version information from Elasticsearch nodes
修改elasticsearch配置
PUT /index/_settings
{
“number_of_replicas”: 0
}
{
“acknowledged” : true
}
查看elasticsearch状态,正常status为green
GET _cluster/health