Vue中[...]作用
...作用是赋值
例:
// 创建实例时设置配置的默认值
const INSTANCE = axios.create({
baseURL: '/api/v1/ticketCard',
timeout: '20000'
});
var app = new Vue({
el: "#ticketCardManage",
data: {
ticketCardList: [],//票卡列表
modelTitle: '模板标题', //模板标题
modelType: 1,//模板操作类型 0添加 1修改 2删除
modelData: '', //操作数据对象
modelUrlList: ['/addTicketCard', '/updateTicketCard', '/deleteTicketCard']
},
mounted() {
this.queryTicketCard();
},
methods: {
//所有票卡数据
queryTicketCard: function () {
INSTANCE.get('ticketCardAll')
.then(res => {
const {code = 500, data = [], msg = '失败'} = res.data;
if (code === 200) {
this.ticketCardList = [...data];
}
})
.catch(function (error) {
//请求处理失败
console.log(error);
})
.finally(() => {
//无论失败与否皆会执行
})
}