diff --git a/src/components/G2/G2.js b/src/components/G2/G2.js index 1e1f3f46..68f1f27a 100644 --- a/src/components/G2/G2.js +++ b/src/components/G2/G2.js @@ -30,12 +30,6 @@ export default { padding: [40, 40, 50, 60] } }, - created () { - // 打印信息 - this.$log('G2', ...[ - `version ${this.G2.version}` - ]) - }, mounted () { // 如果设置了在 mounted 后自动初始化 就在这里初始化 if (this.mountedInit) { @@ -47,6 +41,7 @@ export default { watch: { // 数据改变 data () { + console.log('111') this.changeData() } }, diff --git a/src/components/core/Markdown/index.vue b/src/components/core/Markdown/index.vue index 810bf947..7dbdf260 100644 --- a/src/components/core/Markdown/index.vue +++ b/src/components/core/Markdown/index.vue @@ -50,7 +50,7 @@ export default { }, // 从 url 加载原始数据 async getReadme (name) { - const data = await this.$http.get(name) + const data = await this.$axios.get(name) return this.marked(data) }, marked (data) { diff --git a/src/mock/chart/G2Line1.js b/src/mock/chart/G2Line1.js new file mode 100644 index 00000000..6948d69d --- /dev/null +++ b/src/mock/chart/G2Line1.js @@ -0,0 +1,19 @@ +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 } + ] + } +}) diff --git a/src/mock/index.js b/src/mock/index.js index 5c882f7a..f997f5be 100644 --- a/src/mock/index.js +++ b/src/mock/index.js @@ -1,3 +1,5 @@ import '@/mock/demo/001' import '@/mock/login' + +import '@/mock/chart/G2Line1' diff --git a/src/pages/core/login/index.vue b/src/pages/core/login/index.vue index 465cfe1b..46217996 100644 --- a/src/pages/core/login/index.vue +++ b/src/pages/core/login/index.vue @@ -67,7 +67,7 @@ export default { this.$refs.loginForm.validate((valid) => { if (valid) { // 开始请求登录接口 - this.$http({ + this.$axios({ method: 'post', url: '/login', data: { diff --git a/src/pages/demo/chart/index/index.vue b/src/pages/demo/chart/index/index.vue index 5187a292..af93324b 100644 --- a/src/pages/demo/chart/index/index.vue +++ b/src/pages/demo/chart/index/index.vue @@ -2,7 +2,7 @@ - + @@ -29,23 +29,20 @@ export default { margin: [10, 10], useCssTransforms: true }, - G2Line1Data: [] + // 数据 + G2Line1: [] } }, mounted () { setTimeout(() => { - this.G2Line1Data = [ - { 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 } + const api = [ + '/api/chart/G2Line1' ] - }, 3000) + this.$axios.all(api.map(e => this.$axios.get(e))) + .then(this.$axios.spread((G2Line1) => { + this.G2Line1 = G2Line1 + })) + }, 300) }, methods: { // 改变尺寸 diff --git a/src/pages/demo/plugins/marked/demo.vue b/src/pages/demo/plugins/marked/demo.vue index 1d492417..83d3db28 100644 --- a/src/pages/demo/plugins/marked/demo.vue +++ b/src/pages/demo/plugins/marked/demo.vue @@ -36,7 +36,7 @@ export default { }, methods: { async getReadme () { - const data = await this.$http.get('/static/markdownFiles/demo/baseMarkdowmFile.md') + const data = await this.$axios.get('/static/markdownFiles/demo/baseMarkdowmFile.md') return data } } diff --git a/src/pages/demo/plugins/marked/demoHighlight.vue b/src/pages/demo/plugins/marked/demoHighlight.vue index 0a8c45fb..588ed3b7 100644 --- a/src/pages/demo/plugins/marked/demoHighlight.vue +++ b/src/pages/demo/plugins/marked/demoHighlight.vue @@ -41,7 +41,7 @@ export default { }, methods: { async getReadme () { - const data = await this.$http.get('/static/markdownFiles/demo/baseMarkdowmFile.md') + const data = await this.$axios.get('/static/markdownFiles/demo/baseMarkdowmFile.md') return data } } diff --git a/src/pages/demo/plugins/mock/ajax.vue b/src/pages/demo/plugins/mock/ajax.vue index 186e5a67..76320878 100644 --- a/src/pages/demo/plugins/mock/ajax.vue +++ b/src/pages/demo/plugins/mock/ajax.vue @@ -32,7 +32,7 @@ export default { }, methods: { ajax () { - this.$http.get('/api/demo/001') + this.$axios.get('/api/demo/001') .then(res => { this.table.columns = Object.keys(res.data.list[0]).map(e => ({ label: e, diff --git a/src/plugin/axios/index.js b/src/plugin/axios/index.js index 62f96ca1..29ee0513 100644 --- a/src/plugin/axios/index.js +++ b/src/plugin/axios/index.js @@ -18,4 +18,4 @@ axios.interceptors.response.use(res => { return Promise.reject(err) }) -Vue.prototype.$http = axios +Vue.prototype.$axios = axios