路線更改時,我網(wǎng)站上的元數(shù)據(jù)不會更新。路線本身有一個watch可以很好地更新視圖,但從metaInfo()沒有vue-meta跟上。我的<script>代碼部分如下所示:<script> export default { name: "Product", watch: { '$route.params.ProductID': { deep: true, immediate: true, handler() { this.getProduct(); // calls getProduct() on route change. Can I also call metaInfo() from here somehow? } } }, metaInfo() { return { title: this.Product.ProductTitle, meta: [ { name: 'description', content: this.Product.ProductTitle } ] } }, computed: { Product() { return this.$store.getters.getProduct } }, mounted() { if (this.Product == null || !this.Product.length) { this.getProduct(); } }, methods: { getProduct() { return this.$store.dispatch('loadProduct', {ProductID: this.$route.params.ProductID}) } } }</script>發(fā)生的事情是,當(dāng)我更改路線并從/product/123to/product/124時,metaInfo()仍然顯示/product/123. 如果我點(diǎn)擊刷新,則metaInfo()更新并顯示/product/124.我需要watch觸發(fā)更新metaInfo()但不知道該怎么做。我在任何地方的文檔中都找不到此信息。請幫忙?
如何在路由/網(wǎng)址更改時更新 vue-meta?
UYOU
2022-07-08 10:28:24