# web_proj **Repository Path**: bingly/web_proj ## Basic Information - **Project Name**: web_proj - **Description**: web项目演示 - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-04-16 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 文件地址修改 * 数据库 ``\service\application\database.php`` ```php // 数据库名 'database' => 'hrapp', // 用户名 'username' => 'root', // 密码 'password' => 'root', ``` * 服务端接口的图片地址修改 ``\service\application\common.php`` ```php function fixed_url() { return 'http://localhost/tp/web_proj/service/public/'; } ``` * app的接口地址 ``\app\config\index.js`` ```javascript proxyTable: { '/api': { target: 'http://localhost/', pathRewrite: { '^/api': '/tp/web_proj/service/public/index.php/api' } } } ``` ### 二、项目基本demo演示 > 部署说明 * service文件夹表示服务端,使用tp5框架。 * 使用之前应将数据库(hrapp.sql)导入,并修改service文件夹中/application/database.php的数据库配置,如用户名、密码等 * app文件夹表示客户端,使用``npm install``安装依赖库,``npm run dev``运行 #### 1、tp5的接口开发 * api模块中增加config.php ```php``` return [ // 默认输出类型 'default_return_type' => 'json', ]; * renderSuccess返回操作成功json * renderError返回操作失败json #### 2、axios注意事项 * 引入axios ```javascript import axios from 'axios' ``` * get请求 ```javascript axios.get('/api/login/test.html') .then(function(response){ console.log(response); }) .catch(function(err){ console.log(err); }); ``` * post请求 ```javascript axios.post('/api/login/login.html',{ username: this.username, password: this.password }) .then(function(res){ console.log(res); }) .catch(function(err){ console.log(err); }); ``` * 设置代理:index.js文件中设置proxyTable api对应的地址应改成项目部署的实际地址 ```javascript proxyTable: { '/api': { target: 'http://localhost/', pathRewrite: { '^/api': '/tp/tp5teach/hr/public/index.php/api' } } } ``` #### 3、axios提交post请求,tp5接收会出现错误 ![avatar](./tg_img/axios%20post错误.jpg) * [解决办法:解决方法:将php.ini中的 always_populate_raw_post_data 配置 置为 -1.](https://blog.csdn.net/shaukon/article/details/100011751) #### 4、项目功能分析 * 服务端接口——修改原来管理系统代码 * 增删改查实现