Vuejs3 和 AXIOS 更新变量
Vuejs3 and AXIOS update variable
我用 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>
即使我正确接收数据,“accounts”的值也不会改变。
我错过了什么吗?
非常感谢,
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))
我用 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>
即使我正确接收数据,“accounts”的值也不会改变。 我错过了什么吗?
非常感谢,
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))