我用AXIOS调用POST函数,我想从它中检索一个JSON。我找不到如何更新我的Vuejs 3变量。
<script type="text/javascript">
Vue.createApp({
data() {
return {
name: 'Vue.js',
accounts: "",
}
},
methods: {
refresh_account_list(event) {
axios.defaults.xsrfHeaderName = "X-CSRFTOKEN";
axios.defaults.xsrfCookieName = "csrftoken";
axios.defaults.withCredentials = true;
axios.post('/api/gads/get_accounts', {
mcc_id: 'XXXXXXXX',
}) => (this.accounts = response.data)
}
}
}).mount('#app')
</script>即使我正确地接收数据,“帐户”的值也不会改变。我错过了什么吗?
非常感谢,
发布于 2021-12-24 04:24:02
axios.post('/api/gads/get_accounts', {
mcc_id: 'XXXXXXXX',
}) => (this.accounts = response.data)这实际上是一个错误的语法。应该是这样的:
axios.post('/api/gads/get_accounts', {
mcc_id: 'XXXXXXXX',
}).then(response => (this.accounts = response.data))https://stackoverflow.com/questions/70468735
复制相似问题