如何自定义页面的整体样式
做这个后台管理系统的demo,给领导看后,他直接pass了,原因就是颜色太暗。
所以我们可以改变这个框架的css变量。
/* 统一修改内置的css变量 */ :root { --Layout-aside-width: 220px; /* 全局背景颜色 */ --body-bg: #f4f6f8; --fontFamilyBase: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; --body-color: #595959; /* table背景颜色 */ --background: #fff; --Table-borderColor: #f0f0f0; --Table-color: #595959; --Table-onHover-bg: #fafafa; --Table-onHover-borderColor: #f0f0f0; --Table-onHover-color: #595959; /* table表头 */ --Table-thead-color: #262626; /*筛选表单组件背景颜色 */ --Table-searchableForm-backgroundColor: #fff; /* 表单提示文字颜色 */ --Form-select-placeholderColor: #bfbfbf; --Form-input-placeholderColor: #bfbfbf; --Form-select-borderColor: #e0e0e0; --Form-input-borderColor: #e0e0e0; /* --Form-input-color: #000; */ /* --Form-item-gap: 40px; */ /* 定义表格标题栏操作项偏移的高度 */ --table-title-operator-top: 14px; /* 加载时的背景图片 */ --Spinner-bg: url("data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjY0cHgiIGhlaWdodD0iNjRweCIgdmlld0JveD0iMCAwIDY0IDY0IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPGcgaWQ9Iumhtemdoi0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgICAgICA8ZyBpZD0ibG9hZGluZyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMC41MDAwMDAsIDAuNTAwMDAwKSI+CiAgICAgICAgICAgIDxyZWN0IGlkPSLnn6nlvaIiIHN0cm9rZT0iIzk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gICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg==") }
区分事件和动作
看官方文档中很多组件都可以设置事件,看的是一头雾水。不知道如何去操作。
比如下面的dialog组件中的事件和动作。
网络异常,图片无法展示
|
看完之后不知道怎么去操作。
其实事件就是写在每个组件的onEvent
属性中的。
onEvent: { // 当鼠标移入时触发 mouseenter: { // 配置动作表 actions: [ { actionType: "toast", args: { msg: "toast变量" } } ] }, // 当鼠标移除时触发 mouseleave: { // 配置动作表 actions: [ { actionType: "toast", args: { msg: "离开" } } ] } }
而动作就是写在每个事件中的actions属性中的actionType。见上。
下面我们来看一个例子。其实他就是通过设置mouseenter, mouseleave, click
事件然后配合toast, setValue
来提示用户做了哪些操作,并且修改表单中的值。
{ "type": "page", "body": { "type": "form", id: "form", data: { username: "zh" }, "body": [ { "type": "input-text", "name": "name", "label": "姓名:", value: "${username}" }, { "label": "修改姓名", "name": "name", "type": "button", // "onClick": "props.formStore.setValues({name: 'amis', email: 'amis@baidu.com'});console.log('props', props)", onEvent: { mouseenter: { // 配置动作表 actions: [ { actionType: "toast", args: { msg: "移入", } }, ] }, mouseleave: { // 配置动作表 actions: [ { actionType: "toast", args: { msg: "离开" } } ] }, click: { actions: [ { actionType: "toast", args: { msg: "点击了按钮,并且修改了username" } }, { actionType: "setValue", // 这个一定需要写上哪个组件的id componentId: "form", args: { value: { username: "llm" } } } ] } } } ] } },
网络异常,图片无法展示
|
并不是所有的组件都可以监听click
目的:想要通过icon组件作为一个复制文本的图标,点击后可以复制文本。但是失败了。
{ type: "page", data: { a: "复制的内容" }, body: { type: "icon", icon: "fa fa-files-o", onClick: "console.log('copy.......')", "onEvent": { "click": { "actions": [ { "actionType": "copy", "args": { "copyFormat": "text/html", "content": "${a}" } } ] } } } },
点击页面的icon没有任何反应。
所以这时只能通过button(action)组件来解决。
{ type: "page", data: { a: "复制的内容" }, body: { // type: "icon", type: "action", label: "", icon: "fa fa-files-o", onClick: "console.log('copy.......')", "onEvent": { "click": { "actions": [ { "actionType": "copy", "args": { "copyFormat": "text/html", "content": "${a}" } } ] } } } },
网络异常,图片无法展示
|
关于setValue
动作的解释
它主要是更新数据域中数据的值的。其中通过componentId来绑定更新那个组件中的数据域。
如果不写componentId,那么更新的就是自己数据域中的值,如果写了,就是更新其他数据域中的值。
{ "type": "page", data: { a: "llm" }, id: "pageId", "body": [ { type: "tpl", tpl: "${a}", }, { "type": "form", onEvent: { change: { actions: [ { actionType: "toast", args: { msg: "提示toast" } }, // 直接清空选中的选项 // { // actionType: "clear", // }, { actionType: "setValue", // 这个写的是那个组件id,他就更新那个组件的数据域 componentId: "pageId", args: { value: { a: "${select}" } } // 如果没有写,那么它将绑定的是该组件的id。 // args: { // value: { // select: "a" // } // } } ] } }, "body": [ { "label": "选项", "type": "select", "name": "select", multiple: true, "menuTpl": "<div>${label} 值:${value}, 当前是否选中: ${checked}</div>", "options": [ { "label": "A", "value": "a" }, { "label": "B", "value": "b" }, { "label": "C", "value": "c" } ] } ] } ] },
网络异常,图片无法展示
|
事件动作中获取的event.data
到底是啥
这个我也很迷,结合官网的一个案例,我只知道是当前事件传递的args。
{ "type": "page", "body": [ { "type": "button", "id": "b_001", "label": "发一个广播,携带动作参数", "className": "mb-2", "level": "primary", "onEvent": { "click": { "actions": [ { "actionType": "broadcast", "eventName": "broadcast_1", "args": { "username": "lvxj", "age": 30 }, "description": "一个按钮的点击事件" } ] } } }, { "type": "form", "name": "form1", "id": "form_001", "title": "接收广播事件的参数", "debug": true, "body": [ { "type": "input-text", "id": "form_001_text_01", "label": "年龄", "name": "age", "disabled": false, "mode": "horizontal" }, { "type": "input-text", "id": "form_001_text_02", "label": "usernae", "name": "username", "disabled": false, "mode": "horizontal" } ], "data": { "username": "amis" }, "onEvent": { "broadcast_1": { "actions": [ { "actionType": "reload", "args": { "age": "${event.data.age}", "username": "${event.data.username}" } }, { actionType: "toast", args: { msg: "${event.data | json}" } } ] } } } ] },
网络异常,图片无法展示
|
所以当我们用到了event
这个对象的时候,可以通过这种方式打印出来看一下。
{ "actionType": "toast", "args": { "msgType": "info", "msg": "${event.data | json}" } }