关于 Browser-detect 4.0 的使用方法
最近需要用到一个能够判断当前设备类型的库,于是发现了 Browser-datect
这个神器。看了看官方文档写的非常清楚,打算尝试一下。
由于 Browser-datect
4.0 仅支持 Laravel
6.0 以上版本,所以还特意升级了我的 5.8 版本。然鹅…………接下来我有点懵逼了,文档中提到的那些方法我都调不到,不知道自己在哪里出了错,以下是我的使用方式:
namespace App\Http\Controllers;
use DeviceDetector\Parser\Client\Browser;
class ChatController extends Controller
{
public function index()
{
$mobile = Browser::isMobile(); //这里会报错,isMobile()方法并不存在
dd($mobile);
}
}
Laravel
版本:6.5.1Browser-detect
版本:4.0
推荐文章: