javascript - Vue App API Form 可以在 localhost 上工作,但一旦部署就不行
问题描述
我的代码在我的本地服务器上运行良好,但是一旦我部署到我的网站,我就无法显示数据。我不断收到“由于表单未连接而取消表单提交”。Axios实际上是把数据放到我的数据库中,只是它不会显示在我的界面上。当我 console.log(app.Users) 它返回未定义。谢谢
<script>
var app = new Vue({
el: "#app",
data: {
errorMsg: "",
successMsg: "",
showAddModal: false,
showEditModal: false,
showDeleteModal: false,
users: [],
newUser: { name: "", email: "", phone: "" },
currentUser: {},
},
mounted: function () {
this.getAllUsers();
},
methods: {
getAllUsers() {
axios
.get(
"http://jakewoodruff.com/Projects/crud-vue-php/process.php?action=read"
)
.then(function (response) {
if (response.data.error) {
app.errorMsg = response.data.message;
} else {
app.users = response.data.users;
console.log(app.users);
}
});
},
addUser() {
var formData = app.toFormData(app.newUser);
axios
.post(
"http://jakewoodruff.com/Projects/crud-vue-php/process.php?action=create",
formData
)
.then(function (response) {
app.newUser = { name: "", email: "", phone: "" };
if (response.data.error) {
app.errorMsg = response.data.message;
} else {
app.successMsg = response.data.message;
app.getAllUsers();
}
});
}
解决方案
推荐阅读
- regex - extract string from binary file - regex issue
- openlayers - Continue zooming in when smaller clusters are tapped
- qt - QtQuick 获取基本表单尺寸
- python - 包含(嵌入式)列表理解的字典理解
- xslt - 改变价值
- php - 使用合并运算符和函数调用的最简单方法
- angular - 我什么时候可以检查是否给出了“@Input()”?
- javascript - 内容不显示
- python - np.where() 解决方案说明
- android - 我可以丢弃并重新上传上传到 Playstore 的相同版本的未发布 APK 吗?