效果图:
1. main.js
import axios from 'axios'
Vue.prototype.axios = axios
2.sim.vue
<script>
export default {
name: 'Sim',
beforeRouteEnter: (to, from, next) => {
console.log('进入SIM页面')
next(vm => {
vm.getData()
})
},
beforeRouteLeave: (to, from, next) => {
console.log('离开SIM页面')
next()
},
methods: {
handleClick (row) {
console.log(row)
},
getData: function () {
var _this = this
this.axios({
method: 'get',
url: 'http://localhost:8888/sim/list'
}).then(function (response) {
_this.tableData = response.data.data
}).catch(function (error) {
console.log(e