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)畫示例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Springboot+Vue-Cropper實(shí)現(xiàn)頭像剪切上傳效果
這篇文章主要為大家詳細(xì)介紹了Springboot+Vue-Cropper實(shí)現(xiàn)頭像剪切上傳效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-08-08
VUE3封裝一個(gè)Hook的實(shí)現(xiàn)示例
本文主要介紹了VUE3封裝一個(gè)Hook的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2025-01-01
VUE2響應(yīng)式原理使用Object.defineProperty缺點(diǎn)
這篇文章主要為大家介紹了VUE2響應(yīng)式原理使用Object.defineProperty缺點(diǎn)示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08
vue項(xiàng)目打包并部署到Linux服務(wù)器的詳細(xì)過程
我們?cè)跁?huì)開發(fā)項(xiàng)目的同時(shí),也應(yīng)該了解一下項(xiàng)目是如何部署到服務(wù)器的,下面這篇文章主要給大家介紹了關(guān)于vue項(xiàng)目打包并部署到Linux服務(wù)器的相關(guān)資料,需要的朋友可以參考下2023-01-01

