最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue+ElementUi實現(xiàn)點擊表格鏈接頁面跳轉和路由效果

 更新時間:2024年03月13日 11:14:29   作者:記億揺晃著的那天  
這篇文章主要介紹了Vue+ElementUi實現(xiàn)點擊表格中鏈接進行頁面跳轉和路由,本文結合實例代碼給大家介紹的非常詳細,感興趣的朋友跟隨小編一起看看吧

1、頁面跳轉,先看效果

點擊表格中的asin會跳轉到亞馬遜購物界面

怎么做的呢,直接上代碼

<el-table-column
        prop="asin"
        label="asin"
        width="150"
        fixed>
        <template slot-scope="scope">
          <el-link :href="scope.row.url" rel="external nofollow"  type="primary" target="_blank">{{scope.row.asin}}</el-link>
        </template>
      </el-table-column>

asin那一列通過<template>標簽把scope傳進去,scope是包含這一行的信息的,在標簽里面使用<el-link>標簽配合數(shù)據(jù)里面的url實現(xiàn)頁面跳轉,獲取某個屬性可以通過scope.row.屬性名 獲取

2、路由切換加傳參數(shù),先看效果

 點擊標題

可以看到路由切換到產品分析了,并且asin數(shù)據(jù)也傳遞過去了

實現(xiàn)直接看代碼(需要注意的是需要傳參的話只能使用name屬性,使用path屬性跳轉是不能傳遞參數(shù)的)

<el-table-column
        prop="title"
        label="標題"
        width="150"
        :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <router-link :to= "{name: 'productsAnalysis',params: {asin: scope.row.asin }}">
            <span>
              {{scope.row.title}}
            </span>
          </router-link>
        </template>
      </el-table-column>

可以看到路由切換與頁面跳轉類似,都是通過<template>標簽實現(xiàn)的,區(qū)別就是<router-link>里面直接

{{scope.row.title}}不好使,需要借助<span>標簽實現(xiàn)內容展示

路由切換使用路由名字

productsAnalysis,點擊標題時路由器會找到productsAnalysis路由,并且把參數(shù)params傳過去,看一下我的路由怎么實現(xiàn)的吧

{
    path: '/console',
    component: Layout,
    redirect: '/console/productsAnalysis',
    name: 'console',
    meta: { title: '銷售', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'productsAnalysis',
        name: 'productsAnalysis',
        component: () => import('@/views/products/productsAnalysis'),
        meta: { title: '產品分析', icon: 'table' }
      },
      {
        path: 'productPerspective',
        name: 'productPerspective',
        component: () => import('@/views/products/productPerspective'),
        meta: { title: '產品透視', icon: 'table' }
      }
    ]
  },

可以看到路由名為productsAnalysis的會跳轉到

@/views/products/productsAnalysis組件

 看一下productsAnalysis組件怎么拿到參數(shù)的

<template>
<dev>
  <h1>ProductsAnalysis</h1>
  <h1>{{asin}}</h1>
</dev>
</template>
<script>
import router from '@/router'
export default {
  data(){
    return{
      asin: null
    }
  },
  created() {
    this.asin = this.$route.params.asin
  }
}
</script>
<style scoped>
</style>

直接

this.$route.params.asin就能拿到路由傳過來的參數(shù)

到此這篇關于Vue+ElementUi實現(xiàn)點擊表格中鏈接進行頁面跳轉和路由的文章就介紹到這了,更多相關Vue ElementUi表格鏈接跳轉內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

最新評論

洪江市| 义乌市| 高唐县| 名山县| 建水县| 大宁县| 周宁县| 资源县| 丹巴县| 丰镇市| 昭平县| 邢台县| 德惠市| 元阳县| 德格县| 革吉县| 宜君县| 社会| 武汉市| 陵川县| 双鸭山市| 德格县| 德阳市| 连云港市| 南充市| 璧山县| 大方县| 横峰县| 如皋市| 合肥市| 锡林浩特市| 原平市| 中山市| 康平县| 铜梁县| 芮城县| 陆川县| 青浦区| 三河市| 阳信县| 镇康县|