vue mixins 混入
2019-03-05 19:15
281 查看
版权声明:转载请备注!!! https://blog.csdn.net/qq_39504731/article/details/87895937
vue对于表操作的混入封装
mixins / list.js
export default { data() { return { loading: true, // 遮罩 queryParams: {}, // 查询参数对象 tableData: null, // 表格数据 dataUrl: '', // 表格数据url checkItems: [], // 被选中对象 total: 0 } }, computed: { ids() { const arr = [] this.checkItems.map(v => { arr.push(v.id) }) return arr }, batchStatus() { if (this.checkItems.length > 0) { return true } else { return false } } }, methods: { query() { this.getTableData(this.dataUrl, this.queryParams) }, getTableData(url, params) { // 获取表格数据 this.dataUrl = url this.$http.$get(url, params) .then(res => { this.tableData = res.data.content this.total = res.data.totalElements this.loading = false }) .catch(res => { this.loading = false this.$errorMessage('加载失败,请重试!') }) }, getCheckItems(obj) { // 获取全选数据 this.checkItems = obj }, getPage(current, size) { // 翻页方法 this.queryParams.page = current - 1 // 后台翻页从0开始的所以减1 this.queryParams.size = size this.getTableData(this.dataUrl, this.queryParams) }, deleteTableData(url, id) { // 删除参数为ids的使用当前方法 this.$confirm('您确定删除此条数据吗', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }) .then(() => { this.$http.$post(url, { ids: [id] }).then(res => { if (res.code === '200') { this.$successMessage('删除成功!') this.getTableData(this.dataUrl, this.queryParams) } else { this.$errorMessage('删除失败,' + res.message) } }) }) .catch(() => {}) } } }
相关文章推荐
- Vue.js Mixins 混入使用
- 记一次Vue.js混入mixin的使用(分权限管理页面)
- vue-混入mixin
- vue--mixin混入以及虚拟DOM和diff算法
- Vue中的混入的使用(vue mixins)
- 详解vue项目中如何引入全局sass/less变量、function、mixin
- vue + mixins 使用实例
- vue之mixins混入的简单使用
- Python Mixin混入的使用方法
- Strategy VS Mixin(番外篇)——动态混入扩展方法
- vue中mixin的使用
- Vue混入mixins
- D语言中的混入(Mixin)
- vue中mixin的一点理解
- vue 框架级数据请求 axios(第三方库) fetch(原生) 侦听属性watch 混入mixins
- vue学习第14天,混合mixin
- Vue混入
- Vue——混入
- Vue之mixin全局的用法详解
- Ruby中的Mixin (混入)