vue實(shí)現(xiàn)跳轉(zhuǎn)接口push 轉(zhuǎn)場(chǎng)動(dòng)畫示例
1.index.js 配置子路由children。
import Vue from 'vue' import Router from 'vue-router' import SingerDetail from 'components/singer-detail/singer-detail'
Vue.use(Router)
export default new Router({ routes: [ { path: '/', redirect: '/recommend' }, { path: '/singer', component: Singer, //配置子路由,加一個(gè)參數(shù)children children: [ { //:id 以id為變量,傳遞一個(gè)參數(shù),跳轉(zhuǎn)到不同子路由 path: ':id', component: SingerDetail } ] }, { path: '/search', component: Search, children: [ { path: ':id', component: SingerDetail } ] } ] })
1.Singer
<template> <div class='singer'> <list-view @select='selectSinger'></list-view> //需要用routeview承載子路由 <router-view></router-view> </div> </template>
<script> import listView from '../components/listview' export default{ methods:{ selectSinger(singer){ //vue編程式跳轉(zhuǎn)接口push this.$router.push({ path:'/singer/'+singer.id }) } }, components:{ listView } } </script>
<style> .singer{ } </style>
2.listview (singer子組件)
<template> <div class='listview'> <ul> <li @click='selectItem(item)'></li> </ul> </div> </template>
<script> export default{ methods:{ //內(nèi)部把點(diǎn)擊事件派發(fā)出去,告訴外部我被點(diǎn)擊 selectItem(item){ this.$emit('select',item); } } } </script>
<style> .listview{ } </style>
3.singerDetail
<template> <transition name='slide'> <div class='singer-detail'></div> </transition> </template>
<script> </script>
<style> .singer-detail{ position:fixed z-index:100 top:0 left:0 right:0 bottom:0 background:lightgray } .slider-enter-active,.slider-leave-active{ transition: all 0.3s } .slider-enter,.slider-leave-to{ transform: translate3d(100%,0,0) } </style>
4.push轉(zhuǎn)場(chǎng)動(dòng)畫
<transition name="slide"> <div class="chatdiv"> <div class="back" @click="backAction"></div> <div class="cont">免費(fèi)咨詢專業(yè)醫(yī)生在線解答</div> </div> </transition>
<style> .slide-enter-active,.slide-leave-active{ transition: all 0.3s; } .slide-enter,.slide-leave-to{ transform: translate3d(100%,0,0); } </style>
以上這篇vue實(shí)現(xiàn)跳轉(zhuǎn)接口push 轉(zhuǎn)場(chǎng)動(dòng)畫示例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
vue實(shí)現(xiàn)行列轉(zhuǎn)換的一種方法
這篇文章主要介紹了vue實(shí)現(xiàn)行列轉(zhuǎn)換的一種方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-08-08vue 添加和編輯用同一個(gè)表單,el-form表單提交后清空表單數(shù)據(jù)操作
這篇文章主要介紹了vue 添加和編輯用同一個(gè)表單,el-form表單提交后清空表單數(shù)據(jù)操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-08-08vue :style設(shè)置背景圖片方式backgroundImage
這篇文章主要介紹了vue :style設(shè)置背景圖片方式backgroundImage,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-10-10詳解element上傳組件before-remove鉤子問題解決
這篇文章主要介紹了詳解element上傳組件before-remove鉤子問題解決,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-04-04基于vue+element實(shí)現(xiàn)全局loading過程詳解
這篇文章主要介紹了基于vue+element實(shí)現(xiàn)全局loading過程詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-07-07