javascript - 无法在 vue.js 中将数据从 false 更改为 true
问题描述
我试图将我的数据从 false 更改为 true,以便在付款成功时有条件地呈现按钮。在我的 axios 调用中,我收到了作为子对象中的响应的成功,并且可以 console.log 它。但是,有些东西运行不正常,因为付费仍然返回 false。这应该很简单。有任何想法吗?
<template>
<div>
<h1>SUCCESS!</h1>
<button v-if="paid" v-on:click="confirmPayment">Open PDF</button>
</div>
</template>
<script>
import axios from "axios";
export default {
name: "Success",
data() {
return {
paid: false,
};
},
mounted() {
axios.get("http://localhost:5000/pay/confirm").then((res) => {
console.log(res.data.status);
if (res.data.status == "succeeded") {
console.log(res.data.status);
this.confirmPayment();
}
console.log(this.paid);
});
},
methods: {
confirmPayment() {
this.paid === true;
},
getPDF() {
axios("http://localhost:5000/pdf", {
method: "GET",
responseType: "blob", //Force to receive data in a Blob Format
})
.then((response) => {
const file = new Blob([response.data], { type: "application/pdf" });
const fileURL = URL.createObjectURL(file);
window.open(fileURL);
})
.catch((error) => {
console.log(error);
});
},
},
};
</script>
<style scoped>
h1 {
font-family: "Oswald", sans-serif;
color: white;
}
</style>
解决方案
this.paid === true;
应该this.paid = true;
推荐阅读
- java - 如何打开现有的 android 应用程序并使用颤振向其发送数据
- postgresql - Postgres 在 Schema 中使用 Hstore 给出运算符不存在的错误
- maven - 在“更新 Maven 项目”期间发生内部错误。java.lang.ExceptionInInitializerError
- sql-server - Oracle 和 SQL Server `CEIL/CEILING` 函数返回不同的结果
- python - Matplotlib 返回:AttributeError:'property' 对象没有属性'__name__'
- html - 如何设置比下拉宽度长的下拉项的宽度
- shiny - 有没有办法在闪亮的仪表板上制作布告栏?
- daxstudio - 如何在 Daxstudio 中更改数据库
- css - 在 Docker 容器中编辑 AWX CSS
- java - 检查相机权限返回空对象引用