0%

前言

快速安装

参考地址

安装

yum安装

改变版本只需要把 10改为 11、12、13

1
2
3
4
5
6
7
8
9
# Install the repository RPM:
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# Install PostgreSQL:
yum install -y postgresql10-server

# Optionally initialize the database and enable automatic start:
/usr/pgsql-10/bin/postgresql-10-setup initdb
systemctl enable postgresql-10;systemctl start postgresql-10

查看安装的配置路径

1
2
3
4
5
6
su postgres
# 查看配置文件
psql -U postgres -c 'SHOW config_file'
psql -U postgres
alter user postgres with password 'maxzhao'
\password

退出

1
2
3
4
# 退出
\q
# 切换到 root
su

添加访问

1
2
3
4
5
6
7
8
9
10
11
# 这个地址会变动的,需要根据当前查看的配置文件
# vim /var/lib/pgsql/10/data/postgresql.conf
# 修改配置监听所有的IP
sed -i "s|#listen_addresses = 'localhost'|listen_addresses = '*'|g" /var/lib/pgsql/10/data/postgresql.conf
# 设置IP登录模式
#vim /var/lib/pgsql/10/data/pg_hba.conf
echo "host all all 0.0.0.0/0 md5">>/var/lib/pgsql/10/data/pg_hba.conf
# 重启
systemctl restart postgresql-10
# 查看状态
systemctl status postgresql-10

配置

关闭防火墙

1
2
systemctl stop firewalld
systemctl disable firewalld

备份和恢复

1
2
pg_dump --format=t -d db_name -U user_name -h 127.0.0.1 -O -W  > dump.sql
psql -h 127.0.0.1 -U user_name -d db_name < dump.sql

分布式事物

XA是open group提出的分布式事务处理规范,JTA支持XA规范,JTA只规定了接口,有些应用容器提供实现,也有一些三方的开源实现可用,比如Atomikos。

如果PostgreSQL参与分布式事务(XA)处理,则需要在配置文件postgres.conf中设置参数,此参数用于指定分布式事务中两步提交准备事务的最大数量。默认值为0,此时不支持分布式事务。

max_prepared_transactions参数值不应该小于max_connections参数值,这样每一个session都可以至少有一个可用的准备事务。

1
2
max_connections=100
max_prepared_transactions=100

本文地址: https://github.com/maxzhao-it/blog/post/439bd436/

前言

笔记:创建一个 tab 切换的主页面。

antd 构建 home 页面

1
ng g ng-zorro-antd-mobile:tab-bar-basic  -p app --path="src/app/pages" --styleext='less' --name=home

其中 html 中的标签属性,可以参考后面的 文档记录。

文档记录

建议查询官方文档,下面只是简单的记录
Angular

TabBar 属性

参数 说明 类型 默认值
[activeTab] 当前激活Tab索引 number 0
[barTintColor] tabbar 背景色 string 'white'
[tintColor] 选中的字体颜色 string '#108ee9'
[unselectedTintColor] 未选中的字体颜色 string '#888'
[hidden] 是否隐藏 boolean false
[tabBarPosition] tabbar 位置 `’top’ ‘bottom’`
[prerenderingSiblingsNumber] 预加载两侧Tab数量, -1: 加载所有的tab内容, 0: 仅加载当前tab内容, n: 预加载两侧n个Tab number -1
(onPress) bar 点击触发 EventEmitter<{index: number, title: string, key: string}> -

TabBarItem 属性

参数 说明 类型 默认值
[badge] 徽标数 `number string`
[dot] 是否在右上角显示小红点(在设置badge的情况下失效) boolean false
[icon] 默认展示的内容 TemplateRef -
[selectedIcon] 选中后展示的内容 TemplateRef -
[title] 标题文字 string -
[key] 唯一标识 string -

本文地址: https://github.com/maxzhao-it/blog/post/58472/

前言

笔记:记录组件使用

antd 构建 home 页面

1
ng g ng-zorro-antd-mobile:tab-bar-basic  -p app --path="src/app/pages" --styleext='less' --name=home

其中 html 中的标签属性,可以参考后面的 文档记录。

引入其它插件

引入 Lodash

npm 安装

1
2
3
npm i lodash --save
# TypeScript 提醒
npm i --save-dev @types/lodash

yarn 安装

1
2
3
yarn add lodash
# TypeScript 提醒
yarn add @types/lodash --dev

使用

1
import * as _ from 'lodash';

tsconfig.json

1
2
3
4
5
6
7
8
9
10
11
{
"compilerOptions": {
"types": [
"lodash"
],
"lib": [
"es2018",
"dom"
]
}
}

angular.json

1
2
3
4
5
6
7
8
{
"build": {
"builder": "@angular-devkit/build-angular:browser",
"allowedCommonJsDependencies": [
"lodash"
]
}
}

文档记录

建议查询官方文档,下面只是简单的记录
Angular

TabBar 属性

参数 说明 类型 默认值
[activeTab] 当前激活Tab索引 number 0
[barTintColor] tabbar 背景色 string 'white'
[tintColor] 选中的字体颜色 string '#108ee9'
[unselectedTintColor] 未选中的字体颜色 string '#888'
[hidden] 是否隐藏 boolean false
[tabBarPosition] tabbar 位置 `’top’ ‘bottom’`
[prerenderingSiblingsNumber] 预加载两侧Tab数量, -1: 加载所有的tab内容, 0: 仅加载当前tab内容, n: 预加载两侧n个Tab number -1
(onPress) bar 点击触发 EventEmitter<{index: number, title: string, key: string}> -

TabBarItem 属性

参数 说明 类型 默认值
[badge] 徽标数 `number string`
[dot] 是否在右上角显示小红点(在设置badge的情况下失效) boolean false
[icon] 默认展示的内容 TemplateRef -
[selectedIcon] 选中后展示的内容 TemplateRef -
[title] 标题文字 string -
[key] 唯一标识 string -

DatePicker

参数 说明 类型 默认值
[mode] 日期选择的类型 `’year’ ‘month’
[minDate] 最小可选日期 Date 2000-1-1
[maxDate] 最大可选日期 Date 2030-1-1
[minuteStep] 分钟数递增步长设置 number 1
[locale] 国际化,可覆盖全局[LocaleProvider](https://ng.mobile.ant.design/components/locale-provider/zh)的配置 {DatePickerLocale: {year, month, day, hour, minute, am?, pm?}, okText, dismissText } -
[disabled] 是否不可用 boolean false
[showErrorToast] 显示Toast错误信息 boolean true
[showErrorToastInterval] Toast错误信息显示时间 number 2000
[title] 弹框的标题 `string TemplateRef`
[(ngModel)] 当前选中时间 Date new Date()
(onValueChange) 每列 picker 改变时的回调 EventEmitter<{date: object, index: string}> -
(onOk) 点击选中时执行的回调 EventEmitter<Date> -
(onDismiss) 点击取消时执行的回调 EventEmitter<void> -

注意:日期字符串在不同浏览器有不同的实现,例如 new Date('2017-1-1') 在 Safari 上是 Invalid Date,而在 Chrome 上是能正常解析的。

注意:DatePicker children 建议是 ListItem, 如果不是,需要是自定义组件(组件内需处理 onClick / extra / children 属性)

TextareaItem

参数 说明 类型 默认值
[value] value string -
[defaultValue] 设置初始默认值 string -
[placeholder] placeholder string -
[editable] 是否可编辑 boolean true
[disabled] 是否禁用 boolean false
[clear] 是否带清除功能(仅editabletrue,disabledfalse才生效) boolean false
[rows] 显示几行 number 1
[count] 计数功能,兼具最大长度,默认为0,代表不开启计数功能 number -
[error] 报错样式 boolean false
[autoHeight] 高度自适应, autoHeight 和 rows 请二选一 boolean false
[autoFocus] 初始化自动获得焦点 boolean false
[labelNumber] 定宽枚举值:num * @input-label-width: 34px,可用2-7之间的数字,一般(不能保证全部)能对应显示出相应个数的中文文字(不考虑英文字符) number 5
[name] textarea 的 name string -
[prefixListCls] 列表 className 前缀 string 'am-list'
[title] 文案说明 `string TemplateRef`
[focus] 强制获得焦点 { focus: boolean } -
[(ngModel)] value string -
(onChange) change 事件触发的回调函数 EventEmitter<string> -
(onBlur) blur 事件触发的回调函数 EventEmitter<string> -
(onFocus) focus 事件触发的回调函数 EventEmitter<string> -
(onErrorClick) 点击报错 icon 触发的回调 EventEmitter<void> -

switch

参数 说明 类型 默认值
[checked] 是否默认选中 boolean false
[disabled] 是否不可修改 boolean false
[color] 开关打开后的颜色 string '#4dd865'
[name] switch 的 name string -
[platform] 设定组件的平台特有样式 `’ios’ ‘android’`
[(ngModel)] 当前值 boolean false
(onChange) change 事件触发的回调函数 EventEmitter<boolean> -
(onClick) click事件触发的回调函数,当switch为disabled时,入参的值始终是默认传入的checked值 EventEmitter<boolean> -

Drawer抽屉

参数 说明 类型 默认值
[sidebar] 抽屉里的内容 TemplateRef -
[open] 开关状态 boolean false
[position] 抽屉所在位置 `’left’ ‘right’
[sidebarStyle] - object {}
[contentStyle] - object {}
[overlayStyle] - object {}
[dragHandleStyle] - object {}
[touch] 是否开启触摸手势 boolean true
[transitions] 是否开启动画 boolean true
[docked] 是否嵌入到正常文档流里 boolean false
[enableDragHandle] 是否启用 dragHandle boolean false
[dragToggleDistance] 打开/关闭抽屉时距 sidebar 的拖动距离 number 30
(onOpenChange) open 状态切换时调用 EventEmitter<boolean> -

本文地址: https://github.com/maxzhao-it/blog/post/530/

前言

这个时候应该已经创建了一个项目并且了解基本的文件结构.

路由配置

添加路由依赖

如果创建 App 时,没有添加路由,可以

1
ng generate module app-routing --flat --module=app

src/app/app-routing.module.ts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {LoginComponent} from "./login/login.component";
import {HomeComponent} from "./pages/home/home.component";

const routes: Routes = [
/*重定向 prefix:只要以 path 开头,就会重定向*/
{path: '', redirectTo: '/login', pathMatch: 'full'},
/*登录*/
{path: "login", component: LoginComponent},
/*home*/
{path: "home", component: HomeComponent},
];

@NgModule({
/*初始化路由器*/
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {
}

router 属性说明

引入 app-routing.module.ts 组件

app.module.ts 文件中引入 AppRoutingModule

1
2
3
4
5
6
7
8
9
import {AppRoutingModule} from './app-routing.module';

@NgModule({
declarations: [/****/],
imports: [
AppRoutingModule
/*****/
]
})

添加路由出口

AppComponent添加

1
2
<!-- src/app/app.component.html -->
<router-outlet></router-outlet>

跳转:Router 路由器

1
this.router.navigate(['/home']);
1
<a [routerLink]="['/home']">主页</a>

重定向路由

在用户访问一个特定的地址时,将其重定向到另一个指定的地址。 配置重定向路由:

1
2
3
const appRoutes: Routes = [
{path: '', redirectTo: '/login', pathMatch: 'full'},
];

子路由

子路由配置语法:

1
2
3
4
5
6
7
8
9
10
const appRoutes: Routes = [
{
path: 'home',
component: HomeComponent,
children: [
{ path: '', component: AComponent},
{ path: 'b', component: BComponent}
]
},
];

辅助路由

辅助路由又兄弟路由,配置语法:

1
2
3
4
5
6
7
8
9
10
// 路由配置
{path: 'xxx', component: XxxComponent, outlet:'xxxlet'},
{path: 'yyy', component: XxxComponent, outlet:'yyylet'}

// 使用
<router-outlet></router-outlet>
<router-outlet name="xxxlet"></router-outlet>

// 链接
<a [routerLink]="['/home',{outlets:{xxxlet: 'xxx'}}]">Xxx</a>

当点击Xxx链接时,主插座会显示’/home’链接所对应的组件,而xxxlet插座会显示xxx对应的组件。

路由守卫(guard)

CanActivate/CanActiveChild:处理导航到某路由的情况

当用户不满足这个守卫的要求时就不能到达指定路由。

1
2
3
4
5
6
7
export class DemoGuard1 implements CanActivate {

canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
...
return true;
}
}

CanDeactivate:处理从当前路由离开的情况

1
2
3
4
5
6
7
// 泛型中 AComponent 代表要守卫的组件。
export class DemoGuard2 implements CanDeactivate<AComponent> {
canDeactivate(component: AComponent): boolean {
// 根据 component 的信息进行具体操作
return true;
}
}

Resolve:在路由激活之前获取路由数据

在进入路由时就可以立刻把数据呈现给用户。

1
2
3
4
5
6
7
@Injectable()
export class AResolve implements Resolve<any> {
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const id = route.paramMap.get('id');
// 可以根据路由中的信息进行相关操作
}
}

最后,需要将路由守卫添加到路由配置中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const appRoutes: Routes = [
{
path: 'common/a',
component: AComponent,
canActivate: [DemoGurad1],
canDeactivate: [DemoGuard2],
resolve: {data: AResolve}
},
{ path: 'common/b/:id', component: BComponent },
{ path: '**', component: NotFoundComponent}, // 定义通配符路由
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
...
})

文档记录

建议查询官方文档,下面只是简单的记录
Angular

router 属性

path 地址栏中的URL
component 组建
redirectTo 重定向地址
pathMatch 重定向匹配方式

pathMatch

one of prefix or full

  • prefix:只要以 path 开头,就会重定向,比如 path:'test',则 /test/123会被重定向,但是 /test123/不会被重定向.
  • full: path全部匹配重定向

路由参数

ActivatedRoute 激活的路由 当前激活的路由的路径和参数可以通过 ActivateRoute 的路由服务来获取。

常 用属性:

属性 说明
url 路由路径的 Observable 对象,是一个由路由路径中的各个部分组成的字符串数组.
data 一个 Observable,其中包含提供给路由的 data
对象。也包含由解析守卫(resolve guard)解析而来的值。
paramMap 一个 Observable,其中包含一个由当前路由的必要参数和可选参数组成的 map 对象。用这个 map
可以获取来自同名参数的单一值或多重值。
queryParamMap 一个 Observable,其中包含一个对所有路由都有效的查询参数组成的 map 对象。 用这个 map 可以获取来自查询参数的单一值或多重值。
  • 在查询参数中传递数据
1
/common/b?id=1&name=2 => ActivatedRoute.queryParamMap

在路由路径中传递数据

1
{path: /common/b/:id} => /commo/b/1 => ActivatedRoute.paramMap

在路由配置中传递数据

1
{path: /common/b, component: BComponent, data: {id:“1”, title: “b”}}

示例

constructor(
    private activatedRoute: ActivatedRoute
) { }

ngOnInit() {
   // 从参数中获取
    this.activatedRoute.queryParamMap.subscribe(params => {
      this.id = params.get('id');
    });

   // 或
  // this.activated.snapshot.queryParamMap.get('id');
// 从路径中获取
this.activatedRoute.paramMap.subscribe(params => {
  this.id = params.get('id');
});

this.activatedRoute.data.subscribe(({id,title}) => {

});
}

snapshot: 参数快照,是一个路由信息的静态快照,抓取自组件刚刚创建完毕之后,不会监听路由信息的变化。如果确定一个组件不会从自身路由到自身的话,可以使用参数快照。

subscribe: 参数订阅,相当于一个监听器,会监听路由信息的变化。

本文地址: https://github.com/maxzhao-it/blog/post/15608/

安装

1
npm install -g @angular/cli

思路

添加代理

创建代理文件

proxy.config.json

1
2
3
4
5
6
7
8
9
10
11
{
"/boot": {
"target": "http://127.0.0.1:8888/boot",
"logLevel": "debug",
"secure": false,
"changeOrigin": true,
"pathRewrite": {
"^/boot": "/"
}
}
}

/boot 代理的路径
target 目标暮景
pathRewrite 重写路径
比如代理路径为 /boot/login,则重写的路径为 /login ,
最终为 http://127.0.0.1:8888/boot/login

启动时添加配置文件

package.json 文件中

1
ng serve --port 4100 --proxy-config proxy.config.json

启动命令

1
yarn run start

本文地址: https://github.com/maxzhao-it/blog/post/4317/

安装

1
npm install -g @angular/cli

创建项目

1
2
3
4
5
6
7
8
9
ng new gtboot-app
# 是否使用严格校验
# Would you like to add Angular routing? 是否使用路由
# Which stylesheet format would you like to use? 使用哪种样式表格式?
# 这里选择的 less 与 andv用一样的


cd gtboot-app
ng add ng-zorro-antd-mobile

推荐阅读:

初始化配置

包括引入国际化文件,导入模块,引入样式文件等工作

1
ng add ng-zorro-antd-mobile

启动开发环境

1
2
3
4
ng serve --port 0 --open
# `yarn` 启动
yarn
yarn run start --port 0 --open

修改端口号 --port 端口号 ,当前为 0 则为随机端口号

构建和部署

1
2
3
4
ng build --prod
# `yarn` 构建
yarn
yarn run build

构建 antd

安装组件

1
npm install ng-zorro-antd-mobile --save

引入模块

打开 src/app/app.module.ts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import {NgZorroAntdMobileModule} from 'ng-zorro-antd-mobile';

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
FormsModule,
HttpClientModule,
/** 导入 ng-zorro-antd-mobile 模块 **/
NgZorroAntdMobileModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}

引入样式

angular.json中引入 node_modules/ng-zorro-antd-mobile/src/ng-zorro-antd-mobile.min.css
文件。如果需要自定义主题样式,请参考自定义主题部分。

1
2
3
4
5
6
7
8
9
10
{
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"node_modules/ng-zorro-antd-mobile/src/ng-zorro-antd-mobile.min.css",
"src/styles.css"
]
}

使用官方项目

1
git clone https://gitee.com/mirrors/NG-ZORRO-MOBILE.git

使用脚手架

生成组件参数

1
2
3
4
5
6
7
8
9
10
11
--name 组件名称(必选)
--styleext 样式文件扩展名(默认 css)
--prefix, -p 组件选择器前缀
--inlineStyle, -s 使用行内样式
--inlineTemplate, -t 使用行内模版
--path 指定组件创建目录(相当于执行时所在的目录)
--spec 是否生成 .spec 测试文件
--skipImport 是否跳过模块引入(及导入所属模块)
--selector 选择器名称(默认根据 name 自动生成)
--export 是否将组件声明在模块的 exports
--module, -m 指定要声明的模块名

例如通过以下代码可以快速生成一个导航栏组件,其中nav-bar-basic为对应组件代码演示中的 selector 去除demo-前缀。

1
ng g ng-zorro-antd-mobile:nav-bar-basic -p app --styleext='less' --name=navbar

input-item-basic

开发一个登录页面

1
ng g ng-zorro-antd-mobile:input-item-basic -p app --styleext='less' --name=login

创建 service

/src/app/services路径下创建 service

1
2
ng g service services/user
ng g service services/storage

创建 home 页面

1
ng g ng-zorro-antd-mobile:tab-bar-basic  -p app --path="src/app/pages" --styleext='less' --name=home

创建 mine 我的页面

1
ng g ng-zorro-antd-mobile:list-basic  -p app --path="src/app/pages" --styleext='less' --name=mine

打包

基础打包命令

1
ng build

修改打包后的前端路径

打包后会发现 index.html 中的 <base href="/">

这里想修改 baseUrl

打包命令添加

1
ng build --base-href ./

修改配置文件

1
ng build --prod



有项目路径的打包

比如当前发布的路径为 /app
则需要配置 angular.json 中的

1
{outputPath:"dist/app"}

index.html<base href="/"> 也是必须的。

安装报错问题

setTimeout is not defined

这是 cnpm 安装导致的

卸载重装

1
2
npm uninstall -g @angular/cli
npm install -g @angular/cli --registry=https://registry.npmmirror.com

本文地址: https://github.com/maxzhao-it/blog/post/34236/

Ant-Design官网

a-list

官方介绍与案例很清晰

使用

两种循环方式

一般使用方式一

方式一:

1
2
3
4
5
6
7
8
9
10

<a-list
itemLayout="horizontal"
:dataSource="data">
<a-list-item slot="renderItem"
slot-scope="item, index"
:key="index">

</a-list-item>
</a-list>

方式二:

1
2
3
4
5
6
7
8

<a-list
itemLayout="horizontal">
<a-list-item v-for="(item, index) in activities"
:key="index">

</a-list-item>
</a-list>

a-list-item

参数 说明 类型 默认值
actions 列表操作组,根据 itemLayout 的不同, 位置在卡片底部或者最右侧 Array/ slot
extra 额外内容, 通常用在 itemLayoutvertical 的情况下, 展示右侧内容; horizontal 展示在列表元素最右侧 string|slot -

a-list-item 中, actions属性一定是在最后.

<a-list-item>元素的内部,<a slot="actions">edit</a>的前后位置不会影响按钮在最后.

基本使用方式

a-list-item一般会使用 a-list-item-meta+actions的方式使用. 比如:

属性方式:

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

<a-list-item slot="renderItem"
slot-scope="item, index"
:key="index">
<a-list-item-meta
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
title="title"
description="Ant">
</a-list-item-meta>
<div>content</div>
<a slot="actions">edit</a>
<a slot="actions">more</a>
</a-list-item>

slot 方式:

slot 也不会覆盖a-list-item-meta元素的属性.

但是: slot="avatar" 会覆盖 <a-list-item-meta src="***">

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

<a-list-item slot="renderItem"
slot-scope="item, index"
:key="index">
<a-list-item-meta>
<a-avatar slot="avatar" src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"/>
<a slot="title">title</a>
<span slot="description">Ant</span>
</a-list-item-meta>
<div>content</div>
<a slot="actions">edit</a>
<a slot="actions">more</a>
</a-list-item>

a-list-item-meta

参数 说明 类型 默认值
avatar 列表元素的图标 slot -
description 列表元素的描述内容 string slot
title 列表元素的标题 string slot

参数 avatar 的对应属性为 src
src 列表元素的图标 string -

其她参数

List

官方

参数 说明 类型 默认值 版本
bordered 是否展示边框 boolean false
footer 列表底部 string|slot -
grid 列表栅格配置 object -
header 列表头部 string|slot -
itemLayout 设置 List.Item 布局, 设置成 vertical 则竖直样式显示, 默认横排 string -
loading 当卡片内容还在加载中时,可以用 loading 展示一个占位 boolean|object false
loadMore 加载更多 string|slot -
locale 默认文案设置,目前包括空数据文案 object emptyText: ‘暂无数据’
pagination 对应的 pagination 配置, 设置 false 不显示 boolean|object false
size list 的尺寸 default middle small
split 是否展示分割线 boolean true
dataSource 列表数据源 any[] - 1.5.0
renderItem 自定义Item函数,也可使用 slot=”renderItem” 和 slot-scope=”item, index” (item, index) => vNode -
rowKey 各项 key 的取值,可以是字符串或一个函数 item => string|number

List grid props

官方

参数 说明 类型 默认值
column 列数 number oneOf [ 1, 2, 3, 4, 6, 8, 12, 24] -
gutter 栅格间隔 number 0
xs <576px 展示的列数 number -
sm ≥576px 展示的列数 number -
md ≥768px 展示的列数 number -
lg ≥992px 展示的列数 number -
xl ≥1200px 展示的列数 number -
xxl ≥1600px 展示的列数 number -

本文地址: https://github.com/maxzhao-it/blog/post/50735/

前言

这里用的 Antd pro vue,与 vue 相差不大。

在开发环境中,是可以配置请求代理的。

开发环境与打包后的实际运行环境的配置有很大区别,这里只记录开发环境。

vue.config.js

这里配置的代理路径为 /boot ,当前路径的请求,都会转发到 http://localhost:8888 上。

pathRewrite: { '/': '/', } 表示当前路径不变。

比如,当前请求为 http://127.0.0.1:8000/boot/user/login 则当前请求会被转发到 http://localhost:8888/boot/user/login

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const vueConfig = {
//************
devServer: {
// development server port 8000
port: 8000
// If you want to turn on the proxy, please remove the mockjs /src/main.jsL11
, proxy: {
/*基础接口*/
'/boot': {
target: 'http://localhost:8888',
ws: false,
changeOrigin: true,
pathRewrite: {
'/': '/',
}
},
},
},
}
module.exports = vueConfig;

html 中的图片路径

html 总的图片路径,如果使用的路径格式符合代理规则,则当前 url 也会被代理。

比如说下面两种路径,都会被代理:

- http://127.0.0.1:8000/boot/file/server/view/20210422083822582708935283585024.jpg
- /boot/file/server/view/20210422083822582708935283585024.jpg

本文地址: https://github.com/maxzhao-it/blog/post/54174/

前言

Vue 环境的3个配置文件,没有特殊需要,不要改

  • .env 全局配置:最先加载。
  • .env.development 开发环境,npm run serveyarn run serve 会加载当前配置。
  • .env.preview 上线环境, npm buildyarn build 会加载当前配置;

默认属性

  • NODE_ENV 环境信息
  • BASE_URL 环境地址(如果结尾没有 /,则当前会自动添加 /

自定义配置

自定义配置要以 VUE_APP_ 开头。

本文地址: https://github.com/maxzhao-it/blog/post/17976/