少妇无码太爽了在线播放_久久久综合香蕉尹人综合网_日日碰狠狠添天天爽五月婷_国产欧美精品一区二区三区四区

人參的功效

vue的路由傳參有幾種,vue路由傳參

App.vue組件代碼

<template>  <div>    <p>      <!--使用 router-link 組件進行導航 -->      <!--通過傳遞 `to` 來指定鏈接 -->      <!--設置將router-link渲染為span標簽,默認為a標簽-->      <router-link v-for="item in routerList" :to="'/' + item" custom v-slot="{ navigate }">        <span 
          :class="{spanC: true, activeS: item.split('/')[0] === isA}" 
          @click="navigate(),changeT(item)" 
          @keypress.enter="navigate" 
          role="link">
          {{item.split('/')[0]}}        </span>      </router-link>    </p>    <router-view></router-view>    <span>{{isA}}路由參數{{$route.params}}</span>  </div></template><script>  export default {    name: 'App',
    mounted() {      this.$router.push('/HelloWorld/HelloWorld')
    },
    data() {      return {        routerList: ['HelloWorld/HelloWorld',"HC/HC"],        isA: 'HelloWorld',
      }
    },    components: {
    },    methods: {
      changeT(item) {        this.isA = item.split('/')[0];
      },
    }
  }</script><style scoped>  body {    margin: 0px;    padding: 0px;
  }  .spanC {    padding: 15px;    border: 1px solid #ccc;
  }  .activeS {    background: red;
  }</style>

router.js代碼

import  { createRouter,createWebHashHistory }  from 'vue-router';import HelloWorld from "@/components/HelloWorld.vue";import HC from '@/components/HC.vue'// 1. 定義一些路由// 每個路由都需要映射到一個組件。const routes = [  // 動態字段以冒號開始
  { path: '/HC/:username', component: HC },
  { path: '/HelloWorld/:username', component: HelloWorld },  // 重定向
  { path: '/', redirect: '/HelloWorld' },
]// 2 創建路由實例并傳遞 `routes` 配置// 你可以在這里輸入更多的配置,但我們在這里暫時保持簡單const router = createRouter({  // 3. 內部提供了 history 模式的實現。為了簡單起見,我們在這里使用 hash 模式。  history: createWebHashHistory(),
  routes, // `routes: routes` 的縮寫})// 導出export {
  router
}

效果如下


聯系我們

聯系我們

在線咨詢:

郵件:@QQ.COM

工作時間:周(zhou)一至周(zhou)五,8:30-21:30,節假日不休

關注微(wei)信
關注微信
返回頂部