圆柱
在设置库中编辑 无依赖关系 和小脚印.
说明
malle 允许您在元素上听取特定事件(例如点击,徘徊),并将该元素转换为由函数处理的输入.
事件可以是: 点击或徘徊.
元素可以是 p, (中文(简体) ), div, (中文(简体) ), span,, , , , , , , , .
所创建的输入可以是普通输入或文本区域.
提供功能的用户通常会将 POST 到一个终点取回一些 JSON .
演示
现场演示 : https://deltablot.github.io/malle/ 页面存档备份,存于互联网档案馆
安装
npm i @deltablot/malle
# or
yarn add @deltablot/malle
快速启动
这是一个极小的例子:
import { Malle } from '@deltablot/malle';
// now create the malle
const malle = new Malle({
// this is the function that will be called once user has finished entering text (press Enter or click outside)
// it receives the new value, the original element, the event and the input element
fun: (value, original, event, input) => {
console.log(`New text: ${value}`);
console.log(`Original element:`);
console.log(original);
// add here your code for POSTing the new value
return myFunctionReturingAPromiseString();
},
}).listen(); // directly start listening after object creation
在此示例中,当用户单击元素时 data-malleable='true',该函数在 fun 选项将被调用。 该要素将取而代之: form 内含 input 和可选的动作按钮(提交、取消).
头去 演示 以看到更多实例.
文档
见 API 文档 供使用和可供选择.
维持现状
malle 当前 包含 用于生产环境.
捐款
见 提供文档。 。 。 .
许可证
此软件是开源软件,并按 MIT 许可证。 。 。 .