Mysql 环回应用程序错误ERR_中止404(未找到)
我是个新手。我正在尝试在网页中显示记录列表。我使用mysql作为后端。当我运行服务器时,它运行了2或3分钟,然后服务器关闭了连接。当我向localhost发出请求时,网页没有显示数据库 下面是users.json的代码Mysql 环回应用程序错误ERR_中止404(未找到),mysql,node.js,vue.js,loopback,Mysql,Node.js,Vue.js,Loopback,我是个新手。我正在尝试在网页中显示记录列表。我使用mysql作为后端。当我运行服务器时,它运行了2或3分钟,然后服务器关闭了连接。当我向localhost发出请求时,网页没有显示数据库 下面是users.json的代码 { "name": "users", "plural": "User", "base": "PersistedModel", "idInjection": true, "options": { "validateUpsert": true },
{
"name": "users",
"plural": "User",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"username": {
"type": "string",
"required": true
},
"password": {
"type": "number",
"required": true
},
"createdAt": {
"type": "date",
"required": true
},
"updatedAt": {
"type": "date",
"required": true
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
这是datasource.json文件
{
"db": {
"name": "db",
"connector": "memory"
},
"users": {
"host": "localhost",
"port": 3306,
"url": "",
"database": "shoppingdatabase",
"password": "",
"name": "users",
"user": "root",
"connector": "mysql"
}
}
下面是index.html代码
常数API=http://localhost:3000/api/User/';
让UserApp=new Vue({
el:“#用户应用程序”,
数据:{
用户:[],
用户:{
id:“”,
用户名:“”,
密码:“”,
创建数据:“”,
更新日期:“”,
电子邮件:“”
}
},
已创建:函数(){
这是getUsers();
},
方法:{
getUsers:函数(){
获取(API)
.then(res=>res.json())
。然后(res=>this.users=res);
},
storeUser:函数(){
let法;
console.log('storeCat',this.user);
//处理新的还是旧的
if(this.user.id==''){
删除此.user.id;
方法='POST';
}否则{
方法='PUT';
}
获取(API、{
标题:{
“内容类型”:“应用程序/json”
},
方法:方法,,
正文:JSON.stringify(this.user)
})
.then(res=>res.json())
。然后(res=>{
这是getUsers();
这是reset();
});
},
deleteCat:功能(c){
获取(API+c.id、{
标题:{
“内容类型”:“应用程序/json”
},
方法:“删除”
})
.then(res=>res.json())
。然后(res=>{
这是getUsers();
});
//呼叫重置,因为cat可能处于“活动”状态
这是reset();
},
编辑用户:函数(c){
/*
这一行是坏的,因为它引用了,并且当您键入时,它更新了
列表。用户可能认为他们不需要单击“保存”。
this.cat=c;
*/
this.user.id=c.id;
this.user.username=c.username;
this.user.password=c.password;
this.user.createdAt=c.createdAt;
this.user.updatedAt=c.updatedAt;
this.user.email=c.email;
},
重置:功能(){
this.user.id='';
this.user.username='';
this.user.password='';
this.user.createdAt='';
this.user.updatedAt='';
this.user.email='';
}
}
});
用户列表
身份证件
用户名
暗语
创建日期
更新日期
电子邮件地址
{{user.username}
{{uaer.id}
{{uaer.username}
{{uaer.password}}
{{uaer.createdAt}}
{{uaer.updatedAt}
{{uaer.email}
删去
用户名
暗语
创建日期
更新日期
电子邮件
您真的需要访问/server.js吗?尝试为您的模型创建单独的控制器。或者尝试根据您的需要创建模型。供参考-
把它拿走
从你的html
实际上,您不需要/server.js。
此外,根据您的项目结构,您也没有任何boot/server.js。
“启动”文件夹中只有两个文件是
1.root.js
2.authentication.js