1、【原理:】vue和tp5有自己的路由,但是tp5用来做数据端就不需要这个了,直接设置为vue的nginx配置即可,如下图

2、NGINX设置
location / {
try_files $uri $uri/ /index.html;
}
location ~ ^/(thinkphp|vendor/phpunit|application|runtime)/.*\.php
{
return 404;
}

tp5的运行目录在根目录下的public,将vue打包的文件上传这个目录,然后解压在public就行
3、最后一步
就是api接口问题,要怎么访问?
正常的api接口是:
/api/index/add
现在改动后变成:
/index.php/index/add
网友评论