Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
amis-widget
Advanced tools
Readme
开发amis自定义组件的工具集(支持react、vue2.0和jQuery技术栈)
npm install --save amis-widget
import { registerRendererByType } from 'amis-widget';
class MyReactSelect extends React.PureComponent {
constructor() {
super();
this.handleChange = this.handleChange.bind(this);
}
handleChange(event) {
// 调用amis onToggle 方法,变更选择器表单项值
const {onToggle, options} = this.props;
const option = options.find(o => o.value === event.target.value);
if (onToggle) {
onToggle(option);
}
}
render() {
// 获取表单项 value 和 options 属性
const {label, options, title} = this.props;
return (
<div className="react-select">
<span>
{label}:
</span>
<select onChange={this.handleChange} title={title}>
{options.map(option => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</select>
</div>
);
}
}
// 注册amis普通渲染器
registerRendererByType(MyReactSelect, {
type: 'react-select',
usage: 'renderer', // formitem: amis表单渲染器、options: amis表单控件渲染器
weight: 100,
framework: 'react' // 技术栈类型
});
export default MyReactSelect;
import { registerAmisEditorPlugin } from 'amis-widget';
class ReactSelectPlugin {
rendererName = 'react-select'; // 对应的amis渲染器
$schema = '/schemas/UnkownSchema.json';
name = 'react-select';
description = 'react-select';
tags = ['展示']; // 自定义组件分类
icon = 'fa fa-file-code-o';
order = 100; // 组件面板中的展示优先级,越小越靠前展示
scaffold = { // 插入到页面时需要
type: 'react-select',
label: 'react-select',
name: 'react-select',
options: [
{
label: 'A',
value: 'a'
},
{
label: 'B',
value: 'b'
},
{
label: 'C',
value: 'c'
}
]
};
previewSchema = { // 组件面板预览时需要
type: 'react-select',
label: 'react-select',
options: [
{
label: 'A',
value: 'a'
},
{
label: 'B',
value: 'b'
},
{
label: 'C',
value: 'c'
}
]
};
panelTitle = '下拉框'; // 右侧属性面板Title
panelBody = [ // 右侧属性面板配置项
{
type: 'input-text',
name: 'label',
label: 'label',
value: 'react-select'
},
{
type: 'textarea',
name: 'title',
label: 'hover title',
value: '点击下拉选择数值'
},
{
type: 'tpl',
tpl: '备注:可根据变量 \\${amisUser} 获取用户数据。'
}
];
}
// 注册一个amis-editor插件(仅页面设计器需要,会在自定义组件面板中展示)
registerAmisEditorPlugin(ReactSelectPlugin);
export default ReactSelectPlugin;
FAQs
amis组件注册器(支持react、vue2.0、vue3.0和jQuery技术栈),主要用于注册amis渲染器、amis-editor插件。
We found that amis-widget demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).