日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

vue点击按钮怎么跳转图片_vue-router组件里面点击一个按钮跳转到一个新的组件该怎么实现...

發(fā)布時間:2023/12/10 vue 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue点击按钮怎么跳转图片_vue-router组件里面点击一个按钮跳转到一个新的组件该怎么实现... 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

展開全部

直接修改地址欄中的路由地址即可:

{{msg}}

var testLogin = Vue.component("login",{

template:`

這是我的登錄頁面

`

})

var testRegister = Vue.component("register",{

template:`

這是我的注冊頁面

`

})

//配置路由詞典

//對象數(shù)組

const ?myRoutes =[

//當路由地址:地址欄中的那個路徑是myLogin訪問組件

//組件是作為標簽來用的所以不能直接在component后面使用

//要用返回值

//path:''指定地址欄為空:默認為Login頁面

{path:'',component:testLogin},

{path:'/myLogin',component:testLogin},

{path:'/myRegister',component:testRegister}

]

const myRouter = new VueRouter({

//myRoutes可以直接用上面的數(shù)組替換

routes:myRoutes

})

new Vue({

router:myRouter,

//或者:

/*

router:new VueRouter({

routes:[

{path:'/myLogin',component:testLogin},

{path:'/myRegister',component:testRegister}

]

})

*/

el:"#container",

data:{

msg:"Hello VueJs"

}

})

一、通過router-link實現(xiàn)跳轉

注冊

{{msg}}

var testLogin = Vue.component("login",{

template:`

這是我的登錄頁面

注冊

`

/*to后面是路由地址*/

})

var testRegister = Vue.component("register",{

template:`

這是我的注冊頁面

`

})

//配置路由詞典

const ?myRoutes =[

{path:'',component:testLogin},

{path:'/myLogin',component:testLogin},

{path:'/myRegister',component:testRegister}

]

const myRouter = new VueRouter({

routes:myRoutes

})

new Vue({

router:myRouter,

el:"#container",

data:{

msg:"Hello VueJs"

}

})

二、通過js的編程的方式

jumpToLogin: function () {

this.$router.push('/myLogin');

}

{{msg}}

var testLogin = Vue.component("login",{

template:`

這是我的登錄頁面

注冊

`

/*to后面是路由地址*/

})

var testRegister = Vue.component("register",{

methods:{

jumpToLogin:function(){

this.$router.push('/myLogin');

}

},

template:`

這是我的注冊頁面

注冊完成,去登錄

`

})

//配置路由詞典

const ?myRoutes =[

{path:'',component:testLogin},

{path:'/myLogin',component:testLogin},

{path:'/myRegister',component:testRegister}

]

const myRouter = new VueRouter({

routes:myRoutes

})

new Vue({

router:myRouter,

el:"#container",

data:{

msg:"Hello VueJs"

}

})

總結

以上是生活随笔為你收集整理的vue点击按钮怎么跳转图片_vue-router组件里面点击一个按钮跳转到一个新的组件该怎么实现...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。