useQuasar composable

useQuasar composable是为了获得对[$q对象](/options/the-q-object)的访问。

语法

import { useQuasar } from 'quasar'

setup () {
  const $q = useQuasar()
}

例子

<template>
  <div>
    <div v-if="$q.platform.is.ios">
      Gets rendered only on iOS platform.
    </div>
  </div>
</template>

<script>
import { useQuasar } from 'quasar'

export default {
  setup () {
    const $q = useQuasar()

    console.log($q.platform.is.ios)

    // showing an example on a method, but
    // can be any part of Vue script
    function show () {
      // prints out Quasar version
      console.log($q.version)
    }

    return {
      show
    }
  }
}
</script>