when use script setup, can't use this.$route in template #356
little3201
started this conversation in
General
Replies: 2 comments 2 replies
-
I think you need to remove |
Beta Was this translation helpful? Give feedback.
2 replies
-
When using composition-api, better to do it this way <template>
<router-link
:to="route.path"
class="text-blue-600 font-medium"
v-text="route.name"
></router-link>
</template>
<script>
import { defineComponent, useRoute } from '@nuxtjs/composition-api'
export default defineComponent({
setup() {
const route = useRoute()
return {
route
}
}
})
</script> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
when I use script setup, run yarn dev, everything is ok ,but build, there is an error occurred:
TypeError: Cannot read property '$route' of undefined
the code is :
Beta Was this translation helpful? Give feedback.
All reactions