no message

Former-commit-id: 313b095dffa946b4a4dfffde241353bce31d8cef
Former-commit-id: 049f9d83d669be0ec8267004227e773eb38b96ac
Former-commit-id: 508d4dbe3860eb5e339c116253bb2ff14b01ae3b
This commit is contained in:
李杨
2018-01-28 23:52:37 +08:00
parent 555585b332
commit 3d2201a431
7 changed files with 44 additions and 28 deletions

View File

@@ -41,7 +41,6 @@ export default {
watch: {
// 数据改变
data () {
console.log('111')
this.changeData()
}
},

25
src/mock/chart/G2Line.js Normal file
View File

@@ -0,0 +1,25 @@
import Mock from 'mockjs'
Mock.mock('/api/chart/G2Line', 'post', ({body, type, url}) => {
const _body = JSON.parse(body)
switch (_body.code) {
case 1:
return {
code: 0,
msg: '请求成功',
data: [
{ year: '1991', value: 3 },
{ year: '1992', value: 4 },
{ year: '1993', value: 3.5 },
{ year: '1994', value: 5 },
{ year: '1995', value: 4.9 },
{ year: '1996', value: 6 },
{ year: '1997', value: 7 },
{ year: '1998', value: 9 },
{ year: '1999', value: 13 }
]
}
default:
return {}
}
})

View File

@@ -1,19 +0,0 @@
import Mock from 'mockjs'
Mock.mock('/api/chart/G2Line1', () => {
return {
code: 0,
msg: '请求成功',
data: [
{ year: '1991', value: 3 },
{ year: '1992', value: 4 },
{ year: '1993', value: 3.5 },
{ year: '1994', value: 5 },
{ year: '1995', value: 4.9 },
{ year: '1996', value: 6 },
{ year: '1997', value: 7 },
{ year: '1998', value: 9 },
{ year: '1999', value: 13 }
]
}
})

1
src/mock/chart/index.js Normal file
View File

@@ -0,0 +1 @@
import './G2Line'

1
src/mock/demo/index.js Normal file
View File

@@ -0,0 +1 @@
import './001'

View File

@@ -1,5 +1,12 @@
import '@/mock/demo/001'
import Mock from 'mockjs'
import '@/mock/demo'
import '@/mock/login'
import '@/mock/chart/G2Line1'
import '@/mock/chart'
// 设置全局延时 没有延时的话有时候会检测不到数据变化 建议保留
Mock.setup({
timeout: '600-1000'
})

View File

@@ -34,17 +34,19 @@ export default {
}
},
mounted () {
setTimeout(() => {
this.syncData()
},
methods: {
// 请求图表数据
syncData () {
const api = [
'/api/chart/G2Line1'
{url: '/api/chart/G2Line', data: {code: 1}}
]
this.$axios.all(api.map(e => this.$axios.get(e)))
this.$axios.all(api.map(e => this.$axios.post(e.url, e.data)))
.then(this.$axios.spread((G2Line1) => {
this.G2Line1 = G2Line1
}))
}, 300)
},
methods: {
},
// 改变尺寸
resizeHandler (name) {
this.$nextTick(() => {