no message
Former-commit-id: 0a96bb54e9270e451e59b72e00e35053a7c0e152 Former-commit-id: c250ba90da6546626b9831847630aae786c88344 Former-commit-id: c1182b1bdc6ea9b3934275286a93e2760a643bfe
This commit is contained in:
66
src/pages/demo/plugins/mock/demoDTD.vue
Normal file
66
src/pages/demo/plugins/mock/demoDTD.vue
Normal file
@@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<Container type="ghost">
|
||||
<el-card class="mb">
|
||||
<Markdown url="/static/markdownFiles/article/mock演示页面介绍.md"></Markdown>
|
||||
</el-card>
|
||||
<MockDemoCard
|
||||
v-for="(item, index) in settingDTD"
|
||||
:key="index"
|
||||
:title="item.title"
|
||||
:code="JSON.stringify(item.json, null, 2)"
|
||||
:mock="mockResult[index]"
|
||||
@reload="doMock(index)">
|
||||
</MockDemoCard>
|
||||
<MockDemoCard
|
||||
:title="fn.title"
|
||||
:code="fn.code"
|
||||
:mock="fn.mocked"
|
||||
@reload="fnMock()">
|
||||
</MockDemoCard>
|
||||
<MockDemoCard
|
||||
:title="regexp.title"
|
||||
:code="regexp.code"
|
||||
:mock="regexp.mocked"
|
||||
@reload="regexpMock()">
|
||||
</MockDemoCard>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Vue from 'vue'
|
||||
import * as tool from '@/assets/library/tool/tool.js'
|
||||
import Mock from 'mockjs'
|
||||
import settingDTD from './data/settingDTD'
|
||||
import MockDemoCard from './componnets/MockDemoCard'
|
||||
// mixin
|
||||
import regexp from './mixins/regexp'
|
||||
import fn from './mixins/function'
|
||||
export default {
|
||||
mixins: [
|
||||
regexp,
|
||||
fn
|
||||
],
|
||||
components: {
|
||||
MockDemoCard
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
mockResult: [],
|
||||
settingDTD,
|
||||
settingDTDClone: tool.clone(settingDTD)
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.settingDTD.forEach((e, i) => {
|
||||
this.doMock(i)
|
||||
})
|
||||
this.fnMock()
|
||||
this.regexpMock()
|
||||
},
|
||||
methods: {
|
||||
doMock (n = 0) {
|
||||
Vue.set(this.mockResult, n, JSON.stringify(Mock.mock(this.settingDTDClone[n].json), null, 2))
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user