使用created钩子
import AppLayout from '@/components/app-layout'
import axios from 'axios'
export default {
name: 'home',
data () {
return {
msg: 'Welcome to Your Vue.js home',
name:'test',
IssueDesc: '',
IssueList: [{IssueDesc:"test issue",comments:['123','123345','22222']}],
}
},
components: {AppLayout},
methods: {
changeName: function() {
this.$data.name+='...';
axios.get('static/data/data.json').then(function (resp) {
console.log('XXXX: ',resp)
}).catch(function (err) {
console.log('XXXX: ',err)
})
},
addIssue: function () {
console.log('XXXX: ',this.IssueDesc)
this.IssueList.push({
IssueDesc:this.IssueDesc,
comments:[]
});
}
},
created: function () {
//get init data
console.log('XXXX: ','created')
}
}