基于element-ui封装可配置表单组件

在这里插入图片描述

“vue”: “^2.7.13”
“element-ui”: “^2.15.7”

代码地址

【说明】
该组件时使用vue3(vue2.7)语法封装,使用时可用vue2语法使用也可以使用vue3语法使用

一、vue2语法使用案例

基础用法

<template><div class="form-demo"><div class="form"><BasicForm:schemas="schemas":colProps="{span: 12}":showActionButtonGroup="false"@register="register"@change="handleChange"/></div><div class="btns"><el-button type="primary" @click="saveForm">保存</el-button><el-button @click="resetForm">重置</el-button></div></div>
</template><script>export default {name: 'BasicFormDemo',data() {return {schemas: [{prop: 'id',component: 'Input',show: false // 显示隐藏},{prop: 'username',component: 'Input',label: '姓名',labelWidth: '100px',defaultValue: '张三', // 默认值colProps: {span: 8},required: true},{prop: 'address',component: 'Input',label: '地址',labelWidth: '100px',defaultValue: 1, // 默认值componentProps: {maxlength: 10,showWordLimit: true},colProps: {span: 8}},{prop: 'rate',component: 'Input',label: '税率',labelWidth: '100px',componentProps: {append: '%'},colProps: {span: 8}},{prop: 'url',component: 'Input',label: '网址',labelWidth: '100px',componentProps: {prepend: 'http'},colProps: {span: 8}},{prop: 'inputNumber',component: 'InputNumber',label: '距离',labelWidth: '100px',defaultValue: 1 // 默认值},{prop: 'age',component: 'Switch',label: '年龄',labelWidth: '100px',defaultValue: true // 默认值},{prop: 'remark',component: 'Input',label: '评论',labelWidth: '100px',componentProps: {type: 'textarea',placeholder: '请输入评论'}},{prop: 'divider',component: 'Divider',labelWidth: '0px',componentProps: {contentPosition: 'left',content: '日期类型组件'}},{prop: 'time1',component: 'TimePicker',label: '时间选择器'},{prop: 'time2',component: 'TimePicker',label: '时间选择器',componentProps: {isRange: true,rangeSeparator: '至',startPlaceholder: '开始时间',endPlaceholder: '结束时间',placeholder: '选择时间范围'}},{prop: 'createDate',component: 'DatePicker',label: '创建日期',componentProps: {}},{prop: 'endDate',component: 'DatePicker',label: '带快捷选项',componentProps: {valueFormat: 'yyyy-MM-dd',pickerOptions: {disabledDate(time) {return time.getTime() > Date.now()},shortcuts: [{text: '今天',onClick(picker) {picker.$emit('pick', new Date())}},{text: '昨天',onClick(picker) {const date = new Date()date.setTime(date.getTime() - 3600 * 1000 * 24)picker.$emit('pick', date)}},{text: '一周前',onClick(picker) {const date = new Date()date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)picker.$emit('pick', date)}}]}}},{prop: 'weekly',component: 'DatePicker',label: '周',componentProps: {type: 'week',format: 'yyyy 第 WW 周',placeholder: '请选择周'}},{prop: 'dateRange',component: 'DatePicker',label: '日期范围',componentProps: {type: 'daterange',rangeSeparator: '至',startPlaceholder: '开始日期',endPlaceholder: '结束日期'}},{prop: 'dateRange1',component: 'DatePicker',label: '日期范围-带快捷选项',labelWidth: '140px',componentProps: {type: 'daterange',align: 'right',unlinkPanels: true,rangeSeparator: '至',startPlaceholder: '开始日期',endPlaceholder: '结束日期',pickerOptions: {shortcuts: [{text: '最近一周',onClick(picker) {const end = new Date()const start = new Date()start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)picker.$emit('pick', [start, end])}},{text: '最近一个月',onClick(picker) {const end = new Date()const start = new Date()start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)picker.$emit('pick', [start, end])}},{text: '最近三个月',onClick(picker) {const end = new Date()const start = new Date()start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)picker.$emit('pick', [start, end])}}]}}},{prop: 'monthRange',component: 'DatePicker',label: '月份范围',componentProps: {type: 'monthrange',rangeSeparator: '至',startPlaceholder: '开始月份',endPlaceholder: '结束月份'}},{prop: 'monthRange1',component: 'DatePicker',label: '月份范围-带选项',labelWidth: '130px',componentProps: {type: 'monthrange',align: 'right',unlinkPanels: true,rangeSeparator: '至',startPlaceholder: '开始月份',endPlaceholder: '结束月份',pickerOptions: {shortcuts: [{text: '本月',onClick(picker) {picker.$emit('pick', [new Date(), new Date()])}},{text: '今年至今',onClick(picker) {const end = new Date()const start = new Date(new Date().getFullYear(), 0)picker.$emit('pick', [start, end])}},{text: '最近六个月',onClick(picker) {const end = new Date()const start = new Date()start.setMonth(start.getMonth() - 6)picker.$emit('pick', [start, end])}}]}}},{prop: 'DateTimePicker',component: 'DatePicker',label: '日期时间选择器',labelWidth: '110px',componentProps: {type: 'datetime'}},{prop: 'divider',component: 'Divider',labelWidth: '0px',componentProps: {contentPosition: 'left',content: '单选框'}},{prop: 'radio',component: 'RadioGroup',label: '单选框',defaultValue: '2',colProps: { span: 12 },componentProps: {options: [{label: '1',value: '选项1'},{label: '2',value: '选项2'},{label: '3',value: '选项3',border: true},{label: '4',value: '选项4',disabled: true}]}},{prop: 'divider',component: 'Divider',labelWidth: '0px',componentProps: {contentPosition: 'left',content: '复选框'}},{prop: 'checkbox',component: 'CheckboxGroup',label: '复选框',defaultValue: ['2'],colProps: { span: 12 },componentProps: {options: [{label: '1',value: '选项1'},{label: '2',value: '选项2'},{label: '3',value: '选项3',border: true},{label: '4',value: '选项4',disabled: true}]}},{prop: 'selectAll',component: 'SelectAll',label: '全选',colProps: { span: 12 },defaultValue: ['2'],componentProps: {options: [{label: '1',value: '选项1'},{label: '2',value: '选项2'}]}},{prop: 'divider',component: 'Divider',labelWidth: '0px',componentProps: {contentPosition: 'left',content: '下拉框'}},{prop: 'select',component: 'Select',label: '下拉框',defaultValue: '2',componentProps: {options: [{label: '选项1',value: '1'},{label: '选项2',value: '2',disabled: true}]}},{prop: 'select1',component: 'Select',label: '多选',componentProps: {multiple: true,placeholder: '请选择',options: [{unitName: '选项1',id: '1'},{unitName: '选项2',id: '2',disabled: true}],fieldNames: {label: 'unitName',value: 'id'}}},{prop: 'select11',component: 'ApiSelect',label: '远程下拉框',componentProps: {api: () => this.getOpt(),resultField: 'result',fieldNames: {label: 'unitName',value: 'id'}}},{prop: 'ApiTreeSelect',component: 'ApiTreeSelect',label: '树下拉框',componentProps: {api: () => this.getTreeData(),resultField: 'result',fieldNames: {label: 'name'}}},{prop: 'divider1',component: 'Divider',labelWidth: '0px',componentProps: {contentPosition: 'left',content: '级联选择器'}},{prop: 'Cascader',component: 'Cascader',label: '基本用法',componentProps: {options: [{value: 'zhinan',label: '指南',children: [{value: 'shejiyuanze',label: '设计原则',children: [{value: 'yizhi',label: '一致'},{value: 'fankui',label: '反馈'},{value: 'xiaolv',label: '效率'},{value: 'kekong',label: '可控'}]},{value: 'daohang',label: '导航',children: [{value: 'cexiangdaohang',label: '侧向导航'},{value: 'dingbudaohang',label: '顶部导航'}]}]},{value: 'zujian',label: '组件',children: [{value: 'basic',label: 'Basic',children: [{value: 'layout',label: 'Layout 布局'},{value: 'color',label: 'Color 色彩'},{value: 'typography',label: 'Typography 字体'},{value: 'icon',label: 'Icon 图标'},{value: 'button',label: 'Button 按钮'}]},{value: 'form',label: 'Form',children: [{value: 'radio',label: 'Radio 单选框'},{value: 'checkbox',label: 'Checkbox 多选框'},{value: 'input',label: 'Input 输入框'},{value: 'input-number',label: 'InputNumber 计数器'},{value: 'select',label: 'Select 选择器'},{value: 'cascader',label: 'Cascader 级联选择器'},{value: 'switch',label: 'Switch 开关'},{value: 'slider',label: 'Slider 滑块'},{value: 'time-picker',label: 'TimePicker 时间选择器'},{value: 'date-picker',label: 'DatePicker 日期选择器'},{value: 'datetime-picker',label: 'DateTimePicker 日期时间选择器'},{value: 'upload',label: 'Upload 上传'},{value: 'rate',label: 'Rate 评分'},{value: 'form',label: 'Form 表单'}]},{value: 'data',label: 'Data',children: [{value: 'table',label: 'Table 表格'},{value: 'tag',label: 'Tag 标签'},{value: 'progress',label: 'Progress 进度条'},{value: 'tree',label: 'Tree 树形控件'},{value: 'pagination',label: 'Pagination 分页'},{value: 'badge',label: 'Badge 标记'}]},{value: 'notice',label: 'Notice',children: [{value: 'alert',label: 'Alert 警告'},{value: 'loading',label: 'Loading 加载'},{value: 'message',label: 'Message 消息提示'},{value: 'message-box',label: 'MessageBox 弹框'},{value: 'notification',label: 'Notification 通知'}]},{value: 'navigation',label: 'Navigation',children: [{value: 'menu',label: 'NavMenu 导航菜单'},{value: 'tabs',label: 'Tabs 标签页'},{value: 'breadcrumb',label: 'Breadcrumb 面包屑'},{value: 'dropdown',label: 'Dropdown 下拉菜单'},{value: 'steps',label: 'Steps 步骤条'}]},{value: 'others',label: 'Others',children: [{value: 'dialog',label: 'Dialog 对话框'},{value: 'tooltip',label: 'Tooltip 文字提示'},{value: 'popover',label: 'Popover 弹出框'},{value: 'card',label: 'Card 卡片'},{value: 'carousel',label: 'Carousel 走马灯'},{value: 'collapse',label: 'Collapse 折叠面板'}]}]},{value: 'ziyuan',label: '资源',children: [{value: 'axure',label: 'Axure Components'},{value: 'sketch',label: 'Sketch Templates'},{value: 'jiaohu',label: '组件交互文档'}]}]}},{prop: 'Cascader2',component: 'Cascader',label: '多选',componentProps: {props: { multiple: true },options: [{value: 'zhinan',label: '指南',children: [{value: 'shejiyuanze',label: '设计原则',children: [{value: 'yizhi',label: '一致'},{value: 'fankui',label: '反馈'},{value: 'xiaolv',label: '效率'},{value: 'kekong',label: '可控'}]},{value: 'daohang',label: '导航',children: [{value: 'cexiangdaohang',label: '侧向导航'},{value: 'dingbudaohang',label: '顶部导航'}]}]},{value: 'zujian',label: '组件',children: [{value: 'basic',label: 'Basic',children: [{value: 'layout',label: 'Layout 布局'},{value: 'color',label: 'Color 色彩'},{value: 'typography',label: 'Typography 字体'},{value: 'icon',label: 'Icon 图标'},{value: 'button',label: 'Button 按钮'}]},{value: 'form',label: 'Form',children: [{value: 'radio',label: 'Radio 单选框'},{value: 'checkbox',label: 'Checkbox 多选框'},{value: 'input',label: 'Input 输入框'},{value: 'input-number',label: 'InputNumber 计数器'},{value: 'select',label: 'Select 选择器'},{value: 'cascader',label: 'Cascader 级联选择器'},{value: 'switch',label: 'Switch 开关'},{value: 'slider',label: 'Slider 滑块'},{value: 'time-picker',label: 'TimePicker 时间选择器'},{value: 'date-picker',label: 'DatePicker 日期选择器'},{value: 'datetime-picker',label: 'DateTimePicker 日期时间选择器'},{value: 'upload',label: 'Upload 上传'},{value: 'rate',label: 'Rate 评分'},{value: 'form',label: 'Form 表单'}]},{value: 'data',label: 'Data',children: [{value: 'table',label: 'Table 表格'},{value: 'tag',label: 'Tag 标签'},{value: 'progress',label: 'Progress 进度条'},{value: 'tree',label: 'Tree 树形控件'},{value: 'pagination',label: 'Pagination 分页'},{value: 'badge',label: 'Badge 标记'}]},{value: 'notice',label: 'Notice',children: [{value: 'alert',label: 'Alert 警告'},{value: 'loading',label: 'Loading 加载'},{value: 'message',label: 'Message 消息提示'},{value: 'message-box',label: 'MessageBox 弹框'},{value: 'notification',label: 'Notification 通知'}]},{value: 'navigation',label: 'Navigation',children: [{value: 'menu',label: 'NavMenu 导航菜单'},{value: 'tabs',label: 'Tabs 标签页'},{value: 'breadcrumb',label: 'Breadcrumb 面包屑'},{value: 'dropdown',label: 'Dropdown 下拉菜单'},{value: 'steps',label: 'Steps 步骤条'}]},{value: 'others',label: 'Others',children: [{value: 'dialog',label: 'Dialog 对话框'},{value: 'tooltip',label: 'Tooltip 文字提示'},{value: 'popover',label: 'Popover 弹出框'},{value: 'card',label: 'Card 卡片'},{value: 'carousel',label: 'Carousel 走马灯'},{value: 'collapse',label: 'Collapse 折叠面板'}]}]},{value: 'ziyuan',label: '资源',children: [{value: 'axure',label: 'Axure Components'},{value: 'sketch',label: 'Sketch Templates'},{value: 'jiaohu',label: '组件交互文档'}]}]}},{prop: 'field3',component: 'Cascader',label: '可搜索',componentProps: {filterable: true,props: { label: 'unitName', value: 'id' },options: [{unitName: '神印王座',id: 1,children: [{unitName: '龙皓晨',id: 11},{unitName: '圣彩儿',id: 12}]},{unitName: '吞噬星空',id: 2},{unitName: '天行九歌',id: 3}]}},{prop: 'field3',component: 'ApiCascader',label: 'ApiCascader',componentProps: {filterable: true,props: { label: 'unitName', value: 'id' },api: () => this.getCascaderOpt()}},{prop: 'field4',component: 'Divider',labelWidth: '0px',componentProps: {contentPosition: 'left',content: '上传'}},{prop: 'field4',component: 'Upload',label: '上传附件',componentProps: {action: 'https://httpbin.org/post'}}],formAction: {}}},methods: {register(e) {this.formAction = econsole.log('e', e)},handleChange(e) {console.log('handleChange', e)},saveForm() {this.formAction.validate()console.log('t', this.formAction.getFieldValues())},resetForm() {this.formAction.clearValidate()},getOpt() {return new Promise(resolve => {const result = {result: [{id: '选项1',unitName: '黄金糕'},{id: '选项2',unitName: '双皮奶'},{id: '选项3',unitName: '蚵仔煎'},{id: '选项4',unitName: '龙须面'},{id: '选项5',unitName: '北京烤鸭'},{id: '选项6',unitName: '冰激淋'},{id: '7',unitName: '榴莲千层'},{id: '8',unitName: '煎饼'},{id: '9',unitName: '手抓饼'}]}resolve(result)})},getTreeData() {return Promise.resolve([{id: 118808,parentId: null,name: '新疆',children: [{id: 118809,parentId: 118808,name: '巴州乐禾',children: [{id: 118817,parentId: 118809,name: '采购部'},{id: 118818,parentId: 118809,name: '销售部'},{id: 118824,parentId: 118809,name: '运营部'},{id: 111824,parentId: 113809,name: '研发部'},{id: 118814,parentId: 118829,name: '市场部'}]}]},{id: 118809,parentId: null,name: '广东',children: [{id: 118879,parentId: 118801,name: '广州'}]}])},getCascaderOpt() {return Promise.resolve([{unitName: '神印王座',id: 1,children: [{unitName: '龙皓晨',id: 11},{unitName: '圣彩儿',id: 12}]},{unitName: '吞噬星空',id: 2},{unitName: '天行九歌',id: 3}])}}}
</script>
<style lang="scss">.form-demo {display: flex;flex-direction: column;height: 100%;overflow: hidden;background-color: white;.form {flex: 1;overflow: hidden;}.btns {display: flex;align-items: center;justify-content: flex-end;padding: 16px;box-shadow: 0 -1px #ddd;}}
</style>

可折叠表单

<template><div class="form-demo"><div class="form"><BasicForm:schemas="schemas":colProps="{span: 12}"@register="register"@change="handleChange"/></div></div>
</template><script>export default {name: 'BasicFormDemo',data() {return {schemas: [{prop: 'username',component: 'Input',label: '姓名'},{prop: 'address',component: 'Input',label: '地址'},{prop: 'rate',component: 'Input',label: '税率',componentProps: {append: '%'}}],formAction: {}}},methods: {register(e) {this.formAction = econsole.log('formAction', e)},handleChange(e) {console.log('handleChange', e)}}}
</script>
<style lang="scss">.form-demo {display: flex;flex-direction: column;height: 100%;overflow: hidden;background-color: white;.form {flex: 1;overflow: hidden;}.btns {display: flex;align-items: center;justify-content: flex-end;padding: 16px;box-shadow: 0 -1px #ddd;}}
</style>

设置表单表项值

<template><div class="form-demo"><div class="form"><BasicForm:schemas="schemas":colProps="{span: 12}":showActionButtonGroup="false"@register="register"@change="handleChange"/></div><div class="btns"><el-button type="primary" @click="setFormData">设置值</el-button><el-button type="primary" @click="updateSchema">更新表单项配置项</el-button><el-button type="primary" @click="insetSchema">插入表单项</el-button><el-button type="primary" @click="removeSchemaByFiled">删除表单项</el-button><el-button type="primary" @click="resetSchemas">重置表单</el-button></div></div>
</template><script>export default {name: 'BasicFormDemo',data() {return {schemas: [{prop: 'username',component: 'Input',label: '姓名'},{prop: 'address',component: 'Input',label: '地址'},{prop: 'rate',component: 'Input',label: '税率',componentProps: {append: '%'}}],formAction: {}}},methods: {register(e) {this.formAction = econsole.log('formAction', e)},handleChange(e) {console.log('handleChange', e)},setFormData() {// 调用 setFieldValues 方法可设置表单项值, 返回值是更新之后表单的值const data = this.formAction.setFieldValues({ username: '李四' })console.log('data', data)},updateSchema() {this.formAction.updateSchema({prop: 'rate',component: 'Input',label: '税率',componentProps: {placeholder: '请输入税率'}})},insetSchema() {this.formAction.insetSchema('rate', {prop: 'rate1',component: 'Input',label: '新增',componentProps: {placeholder: '请输入'}})},removeSchemaByFiled() {this.formAction.removeSchemaByFiled('address')},resetSchemas() {this.formAction.resetSchemas()}}}
</script>
<style lang="scss">.form-demo {display: flex;flex-direction: column;height: 100%;overflow: hidden;background-color: white;.form {flex: 1;overflow: hidden;}.btns {display: flex;align-items: center;justify-content: flex-end;padding: 16px;box-shadow: 0 -1px #ddd;}}
</style>

使用插槽 slots

<template><div class="form-demo"><div class="form"><BasicForm :schemas="schemas" :colProps="{span: 24}"><template #username><span>username slot</span></template><template #submitBefore>submit 左侧插槽</template></BasicForm></div></div>
</template><script>export default {name: 'BasicFormDemo',data() {return {schemas: [{prop: 'username',component: 'Input',label: '姓名',slots: 'username'},{prop: 'address',component: 'Input',label: '地址'},{prop: 'rate',component: 'Input',label: '税率',componentProps: {append: '%'}}]}}}
</script>
<style lang="scss">.form-demo {display: flex;flex-direction: column;height: 100%;overflow: hidden;background-color: white;.form {flex: 1;overflow: hidden;}.btns {display: flex;align-items: center;justify-content: flex-end;padding: 16px;box-shadow: 0 -1px #ddd;}}
</style>

二、vue3语法使用

<template><BasicForm@register="register"@submit="handleSubmit"@reset="handleSubmit"@change="handleChange"/>
</template><script setup>
const [register, { updateSchema, getFieldValues, setFieldValues }] = useForm({schemas: [{prop: 'orgUnitId',component: 'ApiSelect',label: 'label1',componentProps: {api: $api.getOrgUnitByUserId,fieldNames: { label: 'departmentName', value: 'id' },resultField: 'result'},required: true},{prop: 'projectId',component: 'Select',label: 'label2',required: true},],labelWidth: '110px'
})
</script>

Form Attributes

参数说明类型可选值默认值
colonlabel 是否显示冒号boolean显示
schemas必填,表单配置项,具体 看下表array
colProps表单项栅格布局,具体看下表objeact
labelWidthlabel 宽度string‘100px’
labelPosition表单域标签的位置,如果值为 left 或者 right 时,则需要设置 label-widthstringright
showActionButtonGroup是否显示操作按钮booleantrue
showSearchBtn是否显示查询按钮booleantrue
showResetBtn是否显示清空按钮Booleantrue
searchText查询按钮文本string‘查询’
resetText清空按钮文本string清空
isFlex是否开启自适应布局booleantrue
formSize尺寸,不同的lebel设置不同的尺寸以适应屏幕, 设置此属性必须设置isFlex为truebooleantrue
model表单数据对象object
isEnterSearch是否按下回车查询booleantrue
formItemMb表单项的 margin-bottomString‘16px’
Schemas Attributes
参数说明类型可选值默认值
colonlabel 是否显示冒号boolean——true
prop必填,字段名称, 唯一string————
component必填,输入框类型,stringInput、InputNumber 、TimePicker、DatePicker、Switch、RadioGroup、CheckboxGroup、SelectAll、Select、ApiSelect、ApiTreeSelect、Cascader、ApiCascader、Upload、Divider——
label标签文本string————
label-width表单域标签的的宽度string——’100px‘
required是否必填boolean——false
show表单项显示隐藏boolean——false
componentProps可设置组件属性(element 组件的属性,具体可查看 element 组件文档),如禁用输入框componentProps={disabled: true}object——{}
defaultValue输入框默认值any————
colProps表单项栅格布局,具体看下表object————
rules表单验证规则array————
disabled是否禁用, 如此处设置表单禁用,无需在 componentProps 中设置false————
slots表单项插槽string————
renderContent渲染内容, 需要返回渲染函数,否则会报错Function————
formItemMb表单项的 margin-bottomString——‘16px’
colProps Attributes
参数说明类型可选值默认值
span栅格占据的列数number——8
xs<768px 响应式栅格数或者栅格属性对象number————
sm≥768px 响应式栅格数或者栅格属性对象number————
md≥992px 响应式栅格数或者栅格属性对象number————
lg≥1200px 响应式栅格数或者栅格属性对象number————
xl≥1920px 响应式栅格数或者栅格属性对象number————

Events

事件名称说明回调参数
change值改变时触发,InputNumber 类型输入如果设置默认值, 初始时会触发一次 change 事件e: any
register注册 BasicForm 组件实例, 获取实例上的方法e: object

Slots

name说明
submitBeforesubmit btn 左侧插槽
resetBeforereset btn 左侧插槽
resetAfterreset btn 右侧插槽
moreAfter更多 右侧插槽

Methods

⚠️ 该组件二次封装后需注册 register事件, 获取实例方法, 并且需要保存到当前组件实例中

方法名说明参数
validate校验
clearValidate清空表单校验
reset清空表单校验, 清空输入框值
getFieldValues获取表单的值
setFieldValues设置表单的值, 返回值是更新之后表单的值object
updateSchema更新表单配置项, prop 必须存在 schemas 中, 不存在则更新失败
insetSchema插入表单项field, schema
removeSchemaByFiled删除表单项field
resetSchemas重置配置项, 恢复初始值

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/133598.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Freeswitch代码

1.引入依赖 Freeswitch依赖版本 <dependency><groupId>org.freeswitch.esl.client</groupId><artifactId>esl-client</artifactId><version>0.10.1</version> </dependency> 2.代码 import org.freeswitch.esl.client.inbound…

2311C++抽象工厂

1,为啥需要工厂设计模式?工厂设计模式可解决什么问题? 先看一下示例,多态示例. #include <iostream> using namespace std; class Shape { public:Shape() { }virtual void drawShape(){cout << "base draw shape" << endl;} }; class Rectang…

python循环改变循环体的操作

问题&#xff1a; python循环时循环体发生改变&#xff1f; 解决办法一 有时候在项目中我们遇到了循环体一直在改变怎么去循环&#xff1f;想到一个办法&#xff0c;记录下来&#xff0c;下次遇到直接上代码就可以。 # 循环一次获取一次 import random xinghao_name [] fo…

VR全景如何助力乡村振兴,乡村发展在哪些方面用到VR全景技术

引言&#xff1a; 乡村振兴是当今中国发展的重要战略&#xff0c;也是推动农村经济社会全面发展的关键举措。在这一过程中&#xff0c;虚拟现实&#xff08;VR&#xff09;全景技术正逐渐崭露头角&#xff0c;为乡村振兴提供了机遇。 一&#xff0e;VR全景技术的概念和应用 1…

[科研图像处理]用matlab平替image-j,有点麻烦,但很灵活!

做材料与生物相关方向的同学应该对image-j并不陌生&#xff0c;前几天有个师兄拜托我用image-j分析一些图片&#xff0c;但使用过后发现我由于不了解image-j的工作流程而对结果并不确信&#xff0c;而且image-j的功能无法拓展&#xff0c;对有些图片的处理效果并不好&#xff0…

SpringBoot获取运行环境 获取静态配置 SpringBoot获取配置文件和属性值 springboot获取配置文件

SpringBoot获取运行环境 获取静态配置 SpringBoot获取配置文件和属性值 springboot获取配置文件 使用 Environment 接口获取更多示例 使用 Environment 接口获取 使用 Environment.getProperty() 配置文件值 例如 获取当前 系统端口号的配置文件值 server.port Environment…

在Google Kubernetes集群创建分布式Jenkins(一)

因为项目需要&#xff0c;在GKE的集群上需要创建一个CICD的环境&#xff0c;记录一下安装部署一个分布式Jenkins集群的过程。 分布式Jenkins由一个主服务器和多个Agent组成&#xff0c;Agent可以执行主服务器分派的任务。如下图所示&#xff1a; 如上图&#xff0c;Jenkins Ag…

Golang爬虫封装

引言 爬虫是一种自动化地从网页中提取信息的程序&#xff0c;它在现代互联网的数据获取和分析中扮演着重要的角色。Golang作为一门强大的编程语言&#xff0c;也提供了丰富的工具和库来实现爬虫功能。在本文中&#xff0c;我们将探讨如何使用Golang来封装一个灵活、高效的爬虫…

ASO优化之为应用创建屏幕截图的技巧(下)

屏幕截图可以激发潜在用户对我们的应用程序的好奇心和兴趣。我们可以使用它们来吸引用户对产品页面的关注&#xff0c;解释应用程序&#xff0c;并强调其解决用户问题的能力。 1、美化屏幕截图背景。 为了使我们的屏幕截图更加有趣和美观&#xff0c;需要考虑使用背景。设计不…

【微服务】一体化智慧工地管理平台源码

智慧工地系统是一种利用人工智能和物联网技术来监测和管理建筑工地的系统。它可以通过感知设备、数据处理和分析、智能控制等技术手段&#xff0c;实现对工地施工、设备状态、人员安全等方面的实时监控和管理。 一、智慧工地让工程施工智能化 1、内容全面&#xff0c;多维度数…

Day1 ARM基础

【ARM课程认知】 1.ARM课程的作用 承上启下 基础授课阶段&#xff1a;c语言、数据结构、linux嵌入式应用层课程&#xff1a;IO、进程线程、网络编程嵌入式底层课程&#xff1a;ARM体系结构、系统移植、linux设备驱动c/QT 2.ARM课程需要掌握的内容 自己能够实现简单的汇编编…

登录Tomcat控制台,账号密码输入正确但点击登录没反应不跳转到控制台页面

在tomcat-users.xml里面可以查看登录tomcat控制台的账号密码&#xff0c;如果账号密码输入正确还是登录不进去&#xff0c;则很有可能是tomcat的账号被锁了&#xff08;可在catalina.xxx.log里面查看&#xff09;。tomcat账号被锁定后默认情况是不访问控制台后5分钟自动解锁&am…

持续集成交付CICD:安装Jenkins Slave(从节点)

目录 一、实验 1.安装Jenkins Slave&#xff08;从节点&#xff09; 二、问题 1.salve节点启动jenkins报错 2.终止命令行后jenkins从节点状态不在线 一、实验 1.安装Jenkins Slave&#xff08;从节点&#xff09; &#xff08;1&#xff09;查看jenkins版本 Version 2.…

Elasticsearch:搜索架构

Elasticsearch 全文检索的复杂性 为了理解为什么全文搜索是一个很难解决的问题&#xff0c;让我们想一个例子。 假设你正在托管一个博客发布网站&#xff0c;其中包含数亿甚至数十亿的博客文章&#xff0c;每个博客文章包含数百个单词&#xff0c;类似于 CSDN。 执行全文搜索…

11月7日 mybatis缓存

mybatis的缓存 缓存的条件&#xff1a;必须要有存在的数据 一级缓存: SqlSession级别缓存.存储的数据.只能在同一个SalSession有效.默认开启 二级缓存: SqlSessionFactory级别的缓存. SqlSessionFactory只有一个的,单例,全局共享的,不同的 SqlSession共享&#xff0c;默认没有…

php多实例

文章目录 安装phpftp扩展查看扩展是否安装成功php-fpm多实例(nginxphp-fpm) 安装php cd /usr/local/src/php-5.6.35/ext/ftp/ /usr/local/php56/bin/phpize ./configure --with-php-config/usr/local/php56/bin/php-config echo $? make echo $? make installftp扩展 vim /…

php 使用phpoffice/phpspreadsheet拓展实现导出图片

基础操作参考&#xff1a;https://blog.csdn.net/huaweichenai/article/details/95994006 文档地址&#xff1a;https://phpspreadsheet.readthedocs.io/ github地址&#xff1a;https://github.com/PHPOffice/PhpSpreadsheet 导出插入图片主要使用\PhpOffice\PhpSpreadshee…

Qt中Opencv转Qimage出现重影或者颜色不对

废话不多说 在qt中opencv获取的图像转qimage时出现重影原因&#xff1a; 图像数据的内存对齐可能会导致画面重影&#xff0c;如果出现误差转换出来的图就会出现重影 解决办法&#xff1a; cv::Mat image_bgr cv::imread(“example.jpg”); cv::Mat image_aligned; cv::copyMak…

3 网络协议入门

从淘宝买东西举例来说明一次请求中的&#xff0c;网络有关的部分是打开浏览器&#xff0c;输入购物网站的地址&#xff1a; https://www.taobao.com/那么浏览器是怎么打开购物网站的首页的呢&#xff1f; (1)首先受到了一段http报文 HTTP/1.1 200 OK Date: Tue, 27 Mar 2018 …

protobufjs实现protobuf序列化与反序列化

系列文章目录 websocket训练地址:https://www.qiulianmao.com,正在搭建中 基础-websocket逆向基础-http拦截基础-websocket拦截基础-base64编码与解码基础-python实现protobuf序列化与反序列化基础-前端js实现protobuf序列化与反序列化基础-protobufjs实现protobuf序列化与反…