成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

如何在Vue中實(shí)現(xiàn)一個(gè)編程式跳轉(zhuǎn)功能

這篇文章主要為大家詳細(xì)介紹了如何在Vue中實(shí)現(xiàn)一個(gè)編程式跳轉(zhuǎn)功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,發(fā)現(xiàn)的小伙伴們可以參考一下:

嵩縣網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)公司,嵩縣網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為嵩縣成百上千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)公司要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的嵩縣做網(wǎng)站的公司定做!

vue是什么軟件

Vue是一套用于構(gòu)建用戶界面的漸進(jìn)式JavaScript框架,Vue與其它大型框架的區(qū)別是,使用Vue可以自底向上逐層應(yīng)用,其核心庫(kù)只關(guān)注視圖層,方便與第三方庫(kù)和項(xiàng)目整合,且使用Vue可以采用單文件組件和Vue生態(tài)系統(tǒng)支持的庫(kù)開(kāi)發(fā)復(fù)雜的單頁(yè)應(yīng)用。

編程式跳轉(zhuǎn)的實(shí)現(xiàn)代碼,如下所示:

<template>
 <ul class = "prolist">
  <!-- //產(chǎn)品 -->
  <!-- :to = "/detail/item.id" -->
  <!-- 聲明式跳轉(zhuǎn) :to = "{ name: 'detail',params: { id: item.id } }" -->
  <!-- <router-link :to = "{ name: 'detail',params: { id: item.id } }" tag = "li" class = "proitem" v-for="(item,index) of iss" :key='index'>
   <div class = "itemimg">
    <img :src="item.images.small" :alt="item.alt">
   </div>
   <div class = "iteminfo">
    <h4>{{ item.title }}</h4>
    <div class = "directors">
     <span v-for="(itm,idx) of item.directors" :key="idx">
      {{ itm.name }}/
     </span>
    </div>
    <Rating :rating='(item.rating.average / 2).toFixed(1)' />
   </div>
  </router-link> -->

  <!-- 編程式跳轉(zhuǎn) -->
  <!-- @click="godetail(item.id) -->
  <li class = "proitem" v-for="(item,index) of iss" @click="goDetail(item.id)" :key='index'>
   <div class = "itemimg">
    <img :src="item.images.small" :alt="item.alt">
   </div>
   <div class = "iteminfo">
    <h4>{{ item.title }}</h4>
    <div class = "directors">
     導(dǎo)演:<span v-for="(itm,idx) of item.directors" :key="idx">
      {{ itm.name }}/
     </span>
    </div>
    <div class = "casts">
      演員:<span v-for="(itm,idx) of item.casts" :key="idx">
      {{ itm.name }}/
     </span>
    </div>
    <Rating :rating="(item.rating.average / 2).toFixed(1)"/>
   </div>
  </li>
 </ul>
</template>
<script>
import Rating from '@/components/common/Rating'

export default {
 methods: {
  goDetail (id) {
   // console.log(this.$router)
   // this.$router.push('/detail/' + id) //id由函數(shù)獲得
   // this.$router.push({ name: 'detail', params: { id: id } }) // 另一種方法
   this.$router.push({ path: '/detail/' + id }) // 另一種方法
  }
 },
 props: ['iss'],
 components: {
  Rating
 }
}
</script>

router.js:
{
   // path: '/detail',
   path: '/detail/:id', // 詳情需要配一個(gè)id,獲取遍歷
   name: 'detail',
   component: () => import('./views/detail/index.vue')
  },

ps:下面看下vue 編程式j(luò)s跳轉(zhuǎn)路由

請(qǐng)看goNews()方法

<template>
  <!-- 所有的內(nèi)容要被根節(jié)點(diǎn)包含起來(lái) -->
  <div id="home">  
    我是首頁(yè)組件
    <button @click="goNews()">通過(guò)js跳轉(zhuǎn)到新聞頁(yè)面</button>
  </div>
</template>
<script>
  export default{
    data(){
      return {        
        msg:'我是一個(gè)home組件'
      }
    },
    methods:{
      goNews(){
        // 注意:官方文檔寫錯(cuò)了
        //第一種跳轉(zhuǎn)方式
        // this.$router.push({ path: 'news' })
        // this.$router.push({ path: '/content/495' });
        //另一種跳轉(zhuǎn)方式
          //  { path: '/news', component: News,name:'news' },
          // router.push({ name: 'news', params: { userId: 123 }})
          this.$router.push({ name: 'news'})
      }
    }
  }
</script>
<style lang="scss" scoped>
</style>

以上就是創(chuàng)新互聯(lián)小編為大家收集整理的如何在Vue中實(shí)現(xiàn)一個(gè)編程式跳轉(zhuǎn)功能,如何覺(jué)得創(chuàng)新互聯(lián)網(wǎng)站的內(nèi)容還不錯(cuò),歡迎將創(chuàng)新互聯(lián)網(wǎng)站推薦給身邊好友。

網(wǎng)頁(yè)標(biāo)題:如何在Vue中實(shí)現(xiàn)一個(gè)編程式跳轉(zhuǎn)功能
路徑分享:http://jinyejixie.com/article24/poceje.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)Google、移動(dòng)網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化、搜索引擎優(yōu)化、微信公眾號(hào)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)
阳原县| 南江县| 清丰县| 融水| 乾安县| 寻乌县| 乾安县| 高碑店市| 扬州市| 莱阳市| 天津市| 奉新县| 长兴县| 乃东县| 海伦市| 顺昌县| 黄平县| 滕州市| 崇左市| 阿巴嘎旗| 和平县| 兴仁县| 晋州市| 大余县| 谷城县| 合川市| 惠来县| 子洲县| 六盘水市| 新竹市| 江孜县| 新兴县| 周口市| 蚌埠市| 托克托县| 广元市| 钟祥市| 筠连县| 沂南县| 乌审旗| 名山县|