forked from zhurui/management
49 lines
1.1 KiB
Markdown
49 lines
1.1 KiB
Markdown
|
数据的获取:
|
|||
|
|
|||
|
经常可以看到在`el-form`中调用函数`getDataList()`,但是在源码中找不到函数`getDataList()`。
|
|||
|
|
|||
|
```vue
|
|||
|
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
|||
|
```
|
|||
|
|
|||
|
实际上这个函数是在`import mixinViewModule from '@/mixins/view-module'`中被实现,其实现如下:
|
|||
|
|
|||
|
```javascript
|
|||
|
getDataList: function () {
|
|||
|
this.page = 1
|
|||
|
this.checkList = {};
|
|||
|
this.query()
|
|||
|
},
|
|||
|
```
|
|||
|
|
|||
|
这里实现的方式似乎相当于对象实例化的方式:
|
|||
|
|
|||
|
```javascript
|
|||
|
import mixinViewModule from '@/mixins/view-module'
|
|||
|
import AddOrUpdate from './user-add-or-update'
|
|||
|
export default {
|
|||
|
mixins: [mixinViewModule],
|
|||
|
data () {
|
|||
|
return {
|
|||
|
mixinViewModuleOptions: {
|
|||
|
// 这里实际上就是getDataList要访问的API
|
|||
|
getDataListURL: '/sys/user/page',
|
|||
|
getDataListIsPage: true,
|
|||
|
deleteURL: '/sys/user',
|
|||
|
deleteIsBatch: true,
|
|||
|
exportURL: '/sys/user/export'
|
|||
|
},
|
|||
|
dataForm: {
|
|||
|
username: '',
|
|||
|
deptId: '',
|
|||
|
gender: ''
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
components: {
|
|||
|
AddOrUpdate
|
|||
|
}
|
|||
|
}
|
|||
|
```
|
|||
|
|