Can I switch assets files to be read using device-detect?

hareku
15
hareku
commented a year ago

Hi. Nuxt.js is awesome framework.
But, i have problem now.

I am using nuxt-device-detect.
https://github.com/dotneet/nuxt-device-detect

I want to dynamically switch assets files to be read using this module.

Or can I specify the path of assets in the head function?

<template>
  <span></span>
</template>

<script>
export default {
  asyncData ({ app }) {
    return { isDesktop: app.$device.isDesktop }
  },

  head () {
    const link = this.isDesktop
      ? '~/assets/app_pc.scss'
      : '~/assets/app_sp.scss'

    return {
      title: 'example',
      link: [
        { rel: 'stylesheet', href: link }
      ]
    }
  }
}
</script>
0
Informations
Question โ€ข Unresolved
#c7526 - Created a year ago