2019-04-29 14:30:04 +08:00
|
|
|
# xm-select
|
|
|
|
|
|
|
|
#### 介绍
|
2019-04-30 11:19:26 +08:00
|
|
|
始于Layui, 下拉选择框的多选解决方案
|
2019-04-29 14:30:04 +08:00
|
|
|
|
2019-09-16 11:01:54 +08:00
|
|
|
前身`formSelectes`, 移除了对`jquery`的依赖, 提高渲染速度
|
|
|
|
|
2019-09-23 20:10:40 +08:00
|
|
|
[xm-select演示站点](https://maplemei.gitee.io/xm-select/)
|
2019-09-23 10:13:26 +08:00
|
|
|
|
2019-09-16 11:01:54 +08:00
|
|
|
> 历史版本
|
|
|
|
|
2019-09-23 20:10:40 +08:00
|
|
|
[前往formSelectes](https://github.com/hnzzmsf/layui-formSelects)
|
2019-09-16 11:01:54 +08:00
|
|
|
|
|
|
|
> 联系方式
|
|
|
|
|
|
|
|
QQ群: 660408068
|
|
|
|
|
|
|
|
|
2019-09-25 17:47:38 +08:00
|
|
|
[更新日志](CHANGELOG.md)
|
2019-09-16 11:01:54 +08:00
|
|
|
|
|
|
|
|
2019-04-29 14:30:04 +08:00
|
|
|
#### 软件架构
|
2019-04-30 11:07:58 +08:00
|
|
|
1. 引入第三方[preact](https://preactjs.com/)库, 利用jsx渲染页面结构
|
|
|
|
2. 使用[webpack](https://www.webpackjs.com/)进行打包
|
2019-04-29 14:30:04 +08:00
|
|
|
|
2019-09-16 11:01:54 +08:00
|
|
|
|
|
|
|
#### 快读上手
|
|
|
|
|
|
|
|
> 直接使用
|
|
|
|
|
|
|
|
```
|
|
|
|
1. 引入 `dist/xm-select.js`
|
|
|
|
2. 写一个`<div id="demo1"></div>`
|
|
|
|
3. 渲染
|
|
|
|
var demo1 = xmSelect.render({
|
|
|
|
el: '#demo1',
|
|
|
|
data: [
|
|
|
|
{name: '水果', value: 1, selected: true, disabled: true},
|
|
|
|
{name: '蔬菜', value: 2, selected: true},
|
|
|
|
{name: '桌子', value: 3, disabled: true},
|
|
|
|
{name: '北京', value: 4},
|
|
|
|
],
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
> 二次开发
|
|
|
|
|
2019-04-30 11:07:58 +08:00
|
|
|
```
|
|
|
|
1. git clone https://gitee.com/maplemei/xm-select.git
|
|
|
|
2. cd xm-select
|
|
|
|
3. yarn 或者 npm install
|
|
|
|
```
|
2019-04-29 14:30:04 +08:00
|
|
|
|
2019-09-16 11:01:54 +08:00
|
|
|
> 打赏
|
|
|
|
|
|
|
|
如果喜欢作者的插件, 可以请作者吃雪糕 ^_^
|
|
|
|
|
|
|
|
<p>
|
|
|
|
<a href="javascript:;">
|
2019-09-26 10:47:22 +08:00
|
|
|
<img src="docs/assets/wx.jpg" alt="打赏" width="300">
|
2019-09-16 11:01:54 +08:00
|
|
|
</a>
|
|
|
|
</p>
|
2019-04-29 14:30:04 +08:00
|
|
|
|
2019-04-30 11:07:58 +08:00
|
|
|
#### 示例
|
|
|
|
|
2019-04-30 11:15:47 +08:00
|
|
|
[示例页面](https://maplemei.gitee.io/xm-select/)
|
|
|
|
|
2019-09-16 11:01:54 +08:00
|
|
|
> 一个小栗子
|
|
|
|
|
2019-04-30 11:07:58 +08:00
|
|
|
```
|
2019-09-16 11:01:54 +08:00
|
|
|
<!-- 占位 -->
|
2019-04-30 11:07:58 +08:00
|
|
|
<div id="demo1"></div>
|
|
|
|
|
|
|
|
|
2019-09-16 11:01:54 +08:00
|
|
|
<!-- 引入插件 -->
|
2019-04-30 11:07:58 +08:00
|
|
|
<script src="../dist/xm-select.js" type="text/javascript" charset="utf-8"></script>
|
2019-09-16 11:01:54 +08:00
|
|
|
<!-- 渲染页面 -->
|
2019-04-30 11:07:58 +08:00
|
|
|
<script type="text/javascript">
|
|
|
|
var demo1 = xmSelect.render({
|
2019-09-16 11:01:54 +08:00
|
|
|
// 这里绑定css选择器
|
2019-04-30 11:07:58 +08:00
|
|
|
el: '#demo1',
|
2019-09-16 11:01:54 +08:00
|
|
|
// 渲染的数据
|
2019-04-30 11:07:58 +08:00
|
|
|
data: [
|
|
|
|
{name: '水果', value: 1, selected: true, disabled: true},
|
|
|
|
{name: '蔬菜', value: 2, selected: true},
|
|
|
|
{name: '桌子', value: 3, disabled: true},
|
|
|
|
{name: '北京', value: 4},
|
|
|
|
],
|
2019-07-23 19:35:09 +08:00
|
|
|
})
|
|
|
|
|
2019-09-16 11:01:54 +08:00
|
|
|
// 变量, demo1 可以通过API操作
|
|
|
|
// 获取选中值, demo1.getValue();
|
|
|
|
// 设置选中值, demo1.setValue([{ name: '动态值', value: 999 }])
|
|
|
|
// ...
|
2019-04-30 11:07:58 +08:00
|
|
|
</script>
|
|
|
|
```
|