Files
layui/examples/transfer.html
sunxiaobin89 5ab142153b ci: 添加 lint 和 format 工具,统一代码格式 (#2905)
* style: 统一代码格式,修复ESLint错误

- 为所有模块添加尾随逗号
- 修复缺少分号的语句
- 统一对象字面量格式
- 添加ESLint配置文件和文档
- 更新package.json中的脚本和依赖项

* build: 添加 ESLint 配置文件以支持 IE9+ 兼容性

* refactor(upload): 使用已缓存的hint实例替换直接调用

优化代码性能,避免重复实例化hint对象,直接使用模块顶部已缓存的实例

* chore: 更新.gitignore文件以包含更多忽略规则

添加了更多常见的临时文件、编辑器文件、构建输出目录和运行时数据的忽略规则,使项目更加整洁并避免不必要的文件被提交到版本控制中

* fix(lay.js): 修复passive事件监听器选项的返回值

确保getter函数返回true以正确支持passive事件监听

* refactor(form): 移除表单模块中的冗余代码

删除表单模块中无实际作用的冗余代码行,这些代码只是将属性重新赋值为自身,没有实际功能意义

* fix(form): 修复复选框状态处理逻辑

确保复选框的 indeterminate 和 checked 状态被正确转换为布尔值,并优化事件调用时的空格格式

* feat(eslint): 完善 ESLint 配置并添加 VSCode 支持

添加 VSCode 配置文件以支持 ESLint 自动修复和格式化
更新 ESLint 配置,增强代码风格和兼容性规则
修复 package.json 中的脚本拼写错误并添加 format 脚本
调整 .gitignore 以允许特定 VSCode 配置文件

* style: 统一代码中的引号格式并修复缩进问题

统一将双引号改为单引号,修复部分代码缩进不一致的问题,提升代码风格一致性

* docs: 删除过时的ESLint配置文档文件

* build: 采用 prettier 作为代码格式化工具,剔除 ESLint 格式化部分

* chore: 剔除 .vscode/ 配置,保持编辑器中立

* build: 修改 ESLint 为「扁平化配置」方式,避免大量参数堆砌

* chore: 格式化代码

* ci: 添加 git hooks 和 CI 环节把关代码风格

* ci: update

* ci: update

* test: 测试 ci format

* ci: 改用 husky 作为 git hooks,与 Layui 3 保持一致

经测试,simple-git-hooks 生成的 pre-commit 默认为 sh,在 Windows 不兼容(必须用 git bash 执行 commits)

* build: 新增 CI 和生产环境跳过 husky 安装的判断

* build: 剔除重复配置

* build: 优化 eslint 配置

---------

Co-authored-by: 贤心 <3277200+sentsim@users.noreply.github.com>
2025-11-10 16:03:37 +08:00

118 lines
3.2 KiB
HTML

<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1"
/>
<title>穿梭框</title>
<link rel="stylesheet" href="../src/css/layui.css" />
<style>
body {
padding: 100px;
}
#text1,
#text2 {
padding-bottom: 60px;
}
</style>
</head>
<body>
<div class="layui-btn-container">
<button type="button" class="layui-btn" lay-demo="getData">
获取右侧数据
</button>
<button type="button" class="layui-btn" lay-demo="reload">
重载实例
</button>
</div>
<div id="text1"></div>
<div class="layui-form">
<div class="layui-form-item">
<label class="layui-form-label">职位</label>
<div class="layui-input-block">
<div id="text2"></div>
</div>
</div>
</div>
<div id="text3"></div>
<script src="../src/layui.js"></script>
<script>
layui.use(['transfer', 'util'], function () {
var $ = layui.$,
transfer = layui.transfer,
util = layui.util;
var ins1 = transfer.render({
elem: '#text1',
title: ['候选文人', '获奖文人'],
data: [
{ value: '1', title: '李白' },
{ value: '2', title: '杜甫' },
{ value: '3', title: '贤心' },
{ value: '11', title: '鲁迅', disabled: true },
{ value: '15', title: '巴金' },
{ value: '16', title: '冰心' },
{ value: '6', title: '冰心' },
{ value: '6', title: '冰心' },
{ value: '6', title: '冰心' },
{ value: '6', title: '冰心' },
{ value: '6', title: '冰心' },
{ value: '6', title: 'Bbb' },
{ value: '6', title: 'BB' },
{ value: '6', title: 'Aa' },
{ value: '6', title: 'aa' }
],
id: 'demoId',
value: ['1', '15', '16'],
showSearch: true // 若区分大小写,设置 'cs'
});
//按钮事件
util.event('lay-demo', {
getData: function (othis) {
alert(JSON.stringify(ins1.getData()));
},
reload: function () {
transfer.reload('demoId', {
value: ['6']
//,data: [{"value": "1", "title": "李白"}]
});
}
});
var ins2 = transfer.render({
elem: '#text2',
showSearch: true,
onchange: function (obj) {
console.log(obj);
},
parseData: function (res) {
return {
value: res.id,
title: res.label,
disabled: res.disabled,
checked: res.checked
};
},
data: [
{ id: '1', label: '瓦罐汤' },
{ id: '2', label: '油酥饼' },
{ id: '3', label: '炸酱面' },
{ id: '4', label: '串串香', disabled: true },
{ id: '5', label: '豆腐脑' },
{ id: '6', label: '驴打滚' }
],
value: ['1', '5']
});
});
</script>
</body>
</html>