Files
mes-ui-d2/src/pages/demo/plugins/mock/ajax.vue
liyang 3e9adc118d flat folder
Former-commit-id: 8f00e0f6b39cbc1e2a9333e2635eed6d3ac4909e [formerly 45b4c97d64e06aa89188acc5f05b8eaaa049fcf5] [formerly 8f00e0f6b39cbc1e2a9333e2635eed6d3ac4909e [formerly 45b4c97d64e06aa89188acc5f05b8eaaa049fcf5] [formerly 8f00e0f6b39cbc1e2a9333e2635eed6d3ac4909e [formerly 45b4c97d64e06aa89188acc5f05b8eaaa049fcf5] [formerly 45b4c97d64e06aa89188acc5f05b8eaaa049fcf5 [formerly dddeab643660d9536ccca28a7b131064862a0956 [formerly a60252b4bb0f8e4357c8fb5d96baa92b34348fd2]]]]]
Former-commit-id: 95c2b6d11f3fca5c35355f6e4462fc48bd75b837
Former-commit-id: 859b43e95cd2d96a6fbccadef42b5ccf030aec0b
Former-commit-id: e095e2d838b165bae833f949655dcd0616dd36a8 [formerly 4457c0c04c4c7dc570cc2fdc8b6c1d9ab63d4e7b]
Former-commit-id: 268d04b33f65537fed5e70f86a765e9d65569458
Former-commit-id: 6895dc7270ebceb21c77c2663ab3ad912b26a02c
Former-commit-id: bb41e9fc1a708ff94371c4c2a7cc14bd6ed40049
Former-commit-id: 5170da37ca33777f225f5ce6e2387ed6d0b1741d
Former-commit-id: c617fbc5781e40482af82fa6bb8ea5105c3e5d9c
2018-12-11 08:48:38 +08:00

58 lines
1.1 KiB
Vue

<template>
<d2-container :filename="filename">
<div slot="header">
<el-button
size="mini"
type="primary"
@click="ajax">
<d2-icon name="paper-plane"/>
发送请求
</el-button>
</div>
<el-table
v-bind="table"
style="width: 100%">
<el-table-column
v-for="(item, index) in table.columns"
:key="index"
:prop="item.prop"
:label="item.label">
</el-table-column>
</el-table>
</d2-container>
</template>
<script>
import { PluginMocksAjax } from '@api/demo.plugins.mocks.ajax'
export default {
name: 'demo-plugins-mock-ajax',
data () {
return {
filename: __filename,
table: {
columns: [],
data: [],
size: 'mini',
stripe: true,
border: true
}
}
},
methods: {
ajax () {
PluginMocksAjax()
.then(res => {
this.table.columns = Object.keys(res.list[0]).map(e => ({
label: e,
prop: e
}))
this.table.data = res.list
})
.catch(() => {
// 错误情况
})
}
}
}
</script>