Vue3 个人信息组件:使用 POST 请求获取数据并渲染
<template>
<div>
<div>{{ account }}</div>
<div>{{ name }}</div>
<div>{{ level }}</div>
</div>
</template>
<script>
import axios from 'axios';
export default {
data() {
return {
account: '',
name: '',
level: '',
};
},
mounted() {
axios.post('/api/getPersonalInfo')
.then(response => {
this.account = response.data.account;
this.name = response.data.name;
this.level = response.data.level;
})
.catch(error => {
console.log(error);
});
},
};
</script>
原文地址: https://www.cveoy.top/t/topic/mmzU 著作权归作者所有。请勿转载和采集!