xm-select/docs/mds/ZTEST.md

40 lines
732 B
Markdown
Raw Normal View History

## 测试
2019-11-22 20:33:17 +08:00
:::demo
```html
<div id="demo1" class="xm-select-demo"></div>
<script>
var demo1 = xmSelect.render({
2019-11-19 20:13:50 +08:00
el: '#demo1',
2020-02-10 14:39:38 +08:00
autoRow: true,
toolbar: { show: true },
2020-05-04 18:56:31 +08:00
paging: true,
pageRemote: true,
filterable: true,
2020-05-04 18:56:31 +08:00
remoteSearch: true,
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-11-22 20:33:17 +08:00
</script>
```
:::