B
ByteNote

导航

首页文章工具关于

© 2025 ByteNote

B
ByteNote

Vue3 useRoute() 获取 path 参数

Jul 25, 20239 min read

在Vue3中,你可以使用useRoute()来获取路由的信息,包括路径参数。以下是一个示例:

import { useRoute } from 'vue-router'

export default {
  setup() {
    const route = useRoute()

    console.log(route.params)

    return {
      ...
    }
  }
}

在示例中,useRoute()返回一个包含当前路由信息的响应式对象route。你可以通过route.params来获取路径参数。

相关文章

Git Merge Mastery: Unveiling the Differences Between Merge, Rebase, and Fast-Forward

Git merging strategies include merge (preserving history), rebase (clean history), and fast-forward (strict, linear merges), each suited for different team collaboration needs.

Solving Local Network Access Issues with DDNS A Comprehensive Guide

This guide provides multiple solutions, including enabling NAT Loopback, using a hosts file, setting up a local DNS server with Dnsmasq, or implementing split-horizon DNS, to resolve the issue of accessing local network services via a Dynamic DNS domain name from within the same network.

Complete Guide to WireGuard VPN Setup Server and All Clients

This comprehensive guide provides step-by-step instructions for setting up a WireGuard VPN server using Docker, configuring clients on Linux, MacOS, mobile devices, and Windows, and managing the server and clients for optimal security and performance.