下載下傳
使用
1、建立
mock.js
import Mock from 'mockjs'
Mock.mock("/getTest",{
"name1|1-3": 'a',
"name2|2": 'b',
});
2、建立
vue
檔案
<template>
<div>
<button type="button" @click="getTest">mock一下</button>
</div>
</template>
<script>
export default {
methods: {
getTest() {
this.$axios.get("/getTest").then(function (res) {
console.log(res.data);
});
}
}
};
</script>
3、
main.js