Former-commit-id: 85b7eab49c2dc78468172c3746fe9144b6eb3544 Former-commit-id: e6e5da925e91f568a3950b9e988b4d4996cf5bf5 Former-commit-id: 75fc437dff21eb7120b2518771d6bde731a5c75d
46 lines
1.1 KiB
Vue
46 lines
1.1 KiB
Vue
<template>
|
|
<d2-container type="ghost">
|
|
<el-card class="d2-mb">
|
|
<d2-demo-page-header slot="header" title="数据占位符"/>
|
|
<d2-markdown url="/static/md/插件 - mock演示页面介绍.md"/>
|
|
</el-card>
|
|
<MockDemoCard
|
|
v-for="(item, index) in settingDPD"
|
|
:key="index"
|
|
:title="item.title"
|
|
:code="JSON.stringify(item.json, null, 2)"
|
|
:mock="mockResult[index]"
|
|
@reload="doMock(index)">
|
|
</MockDemoCard>
|
|
</d2-container>
|
|
</template>
|
|
|
|
<script>
|
|
import Vue from 'vue'
|
|
import clone from '@/utils/clone.js'
|
|
import Mock from 'mockjs'
|
|
import settingDPD from './data/settingDPD'
|
|
export default {
|
|
components: {
|
|
MockDemoCard: () => import('./components/MockDemoCard')
|
|
},
|
|
data () {
|
|
return {
|
|
mockResult: [],
|
|
settingDPD,
|
|
settingDPDClone: clone(settingDPD)
|
|
}
|
|
},
|
|
mounted () {
|
|
this.settingDPD.forEach((e, i) => {
|
|
this.doMock(i)
|
|
})
|
|
},
|
|
methods: {
|
|
doMock (n = 0) {
|
|
Vue.set(this.mockResult, n, JSON.stringify(Mock.mock(this.settingDPDClone[n].json), null, 2))
|
|
}
|
|
}
|
|
}
|
|
</script>
|