nuxt 通过服务端检测设备类型 判断PC 还是 移动端

npm install nuxt-user-agent

 

// nuxt.config.js
modules: [
'nuxt-user-agent',
]

async asyncData({ $indexApi, store, route, $baseConfigId, $accessKey, $ua }) {

    let equipment = ''
    if ($ua._parsed.category === 'pc') {
      equipment = 'pc'
    } else {
      equipment = 'h5'
    }
posted @ 2023-08-14 14:13  卢老师不想编程  阅读(451)  评论(0编辑  收藏  举报