vuejs3,无法使用usehead元包添加动态标题和描述

vuejs3, cannot add dynamic title and description with usehead meta package

我一直在尝试使用 Vue Js 3 useHead 包并添加动态标题和描述元,但我得到 $route is undefined....我需要帮助...

<router-link :to="{name:'productDetails', params:{id:rope._id, title:rope.title, price: rope.price, description:rope.description, quantity:rope.totalQuantity}}">

peoductDetails.vue:

 setup(){

    useHead({
      title: this.$route.params.title,
      meta: [
        {
          name: `description`,
          content: `blalala`
        },
      ],
    })
  },

您需要使用useRoute() in order to access the router, since in the setup hook this does not refer to the component instance

setup(){
    const route = useRoute();
    useHead({
        title: route.params.title,
        meta: [
            {
                name: `description`,
                content: `blalala`
            },
        ],
    })
},