2019-10-10 14:30:04 +08:00
|
|
|
## 测试
|
|
|
|
|
2019-11-22 20:33:17 +08:00
|
|
|
:::demo
|
|
|
|
```html
|
|
|
|
<div id="demo1" class="xm-select-demo"></div>
|
|
|
|
|
|
|
|
<script>
|
2019-10-10 14:30:04 +08:00
|
|
|
var demo1 = xmSelect.render({
|
2019-11-19 20:13:50 +08:00
|
|
|
el: '#demo1',
|
2020-02-10 14:39:38 +08:00
|
|
|
autoRow: true,
|
2020-07-31 12:11:39 +08:00
|
|
|
toolbar: { show: true },
|
2020-05-04 18:56:31 +08:00
|
|
|
paging: true,
|
|
|
|
pageRemote: true,
|
2020-07-31 12:11:39 +08:00
|
|
|
filterable: true,
|
2020-05-04 18:56:31 +08:00
|
|
|
remoteSearch: true,
|
2020-07-31 12:11:39 +08:00
|
|
|
remoteMethod: function(val, cb, show){
|
|
|
|
//这里如果val为空, 则不触发搜索
|
|
|
|
/* if(!val){
|
|
|
|
return cb([]);
|
|
|
|
} */
|
|
|
|
//这里引入了一个第三方插件axios, 相当于$.ajax
|
|
|
|
axios({
|
|
|
|
method: 'get',
|
|
|
|
url: 'https://www.fastmock.site/mock/98228b1f16b7e5112d6c0c87921eabc1/xmSelect/search',
|
|
|
|
params: {
|
|
|
|
keyword: val,
|
|
|
|
}
|
|
|
|
}).then(response => {
|
|
|
|
var res = response.data;
|
|
|
|
cb(res.data, 80)
|
|
|
|
}).catch(err => {
|
|
|
|
cb([]);
|
|
|
|
});
|
2020-05-04 18:56:31 +08:00
|
|
|
},
|
2019-10-10 14:30:04 +08:00
|
|
|
})
|
2019-12-18 14:38:35 +08:00
|
|
|
|
2019-11-22 20:33:17 +08:00
|
|
|
</script>
|
|
|
|
```
|
2019-10-10 14:30:04 +08:00
|
|
|
:::
|