Sfoglia il codice sorgente

mockjs模拟数据测试

daxiongYang 7 anni fa
parent
commit
44f6c72223
5 ha cambiato i file con 25 aggiunte e 1 eliminazioni
  1. 1 0
      package.json
  2. 1 0
      src/main.js
  3. 12 0
      src/mock/index.js
  4. 10 0
      src/mock/modules/common.js
  5. 1 1
      static/config/index.js

+ 1 - 0
package.json

@ -24,6 +24,7 @@
24 24
    "gulp-replace": "0.6.1",
25 25
    "gulp-shell": "0.6.5",
26 26
    "lodash": "4.17.5",
27
    "mockjs": "1.0.0",
27 28
    "vue": "2.5.2",
28 29
    "vue-cookie": "1.1.4",
29 30
    "vue-router": "3.0.1",

+ 1 - 0
src/main.js

@ -5,6 +5,7 @@ import App from './App'
5 5
import router from './router'       // api: https://router.vuejs.org/
6 6
import store from './store'         // api: https://vuex.vuejs.org/
7 7
import VueCookie from 'vue-cookie'  // api: https://github.com/alfhen/vue-cookie
8
// import '@/mock'
8 9
import '@/element-ui'               // api: https://github.com/ElemeFE/element
9 10
import '@/iconfont'                 // api: http://www.iconfont.cn/
10 11
import '@/assets/scss/index.scss'

+ 12 - 0
src/mock/index.js

@ -0,0 +1,12 @@
1
import Mock from 'mockjs'
2
import requestUrl from '@/api/requestUrl'
3
import './modules/common'
4
5
var data = {
6
  code: 1,
7
  name: 'daxiong',
8
  'datas|1-10': [{}]
9
}
10
Mock.mock(requestUrl('/sys/login'), 'post', data)
11
12
export default Mock

+ 10 - 0
src/mock/modules/common.js

@ -0,0 +1,10 @@
1
import Mock from 'mockjs'
2
3
// 登录
4
export function login () {
5
  var res = {
6
    code: 1,
7
    name: 'daxiong'
8
  }
9
  Mock.mock('/sys/login', 'post', res)
10
}

+ 1 - 1
static/config/index.js

@ -4,7 +4,7 @@
4 4
;(function () {
5 5
  window.SITE_CONFIG = {}
6 6
  // api接口请求地址
7
  window.SITE_CONFIG.baseUrl = '//dev.demo.renren.io/renren-fast/'
7
  window.SITE_CONFIG.baseUrl = '//dev.demo.renren.io/renren-fast'
8 8
9 9
  // 嵌套iframe地址
10 10
  window.SITE_CONFIG.nestIframeUrl = '//demo.renren.io/renren-fast/'