Vue 编程式导航,路由history模式
import Vue from 'vue'
import App from './App.vue' import Home from './components/Home.vue'
import News from './components/News.vue' import VueRouter from 'vue-router'
Vue.use(VueRouter) const routes = [
{ path: '/home', component: Home },
{ path: '/news', component: News,name:'newss' },
{ path: '*', redirect: '/home' }
] const router = new VueRouter({ routes,mode:'history' }); new Vue({
el: '#app',
router,
render: h => h(App)
})
<template>
<div id="home">
我是Home组件
<button @click="TiaoZhuan()">跳转到News【path】</button>
<button @click="TiaoZhuanName()">跳转到News【name】</button>
</div>
</template> <script>
export default{
methods:{
TiaoZhuan(){
this.$router.push({path:'news'})
},
TiaoZhuanName(){
this.$router.push({name:'newss'})
}
}
}
</script>
<template>
<div id="news">
我是News组件
</div>
</template>
Vue 编程式导航,路由history模式的更多相关文章
- Vue 路由的编程式导航与history模式
编程式导航 注意:官方文档写错了 通过javascript跳转 //第一种跳转方式 // this.$router.push({ path: 'news' }) // this.$router.pus ...
- vue编程式导航,命名路由
//使用 window.location.href 的形式,叫做 编程式导航 绑定事件的形式 <template> <div class="goods-item" ...
- vue编程式导航
vue项目中使用到了组件间传值,通过路由跳转实现从产品页进入产品详情页查看功能. 使用了this.$router.push(编程式导航) product页面中:因为只需要遮住产品列表页来显示产品详情页 ...
- 编程式导航路由跳转到当前路由(参数不变), 多次执行会抛出NavigationDuplicated的警告错误?
注意:编程式导航(push|replace)才会有这种情况的异常,声明式导航是没有这种问题,因为声明式导航内部已经解决这种问题. 这种异常,对于程序没有任何影响的. 为什么会出现这种现象: 由于vue ...
- Vue 编程式导航(通过js跳转页面)以及路由hash模式和history模式
第一种方法: this.$router.push({path:'shopcontent?aid=3'} 第二种方法 this.$router.push({name:'news'}} 通过在ma ...
- Vue路由编程式导航以及hash模式
import Vue from 'vue'; import App from './App.vue'; //引入公共的scss 注意:创建项目的时候必须用scss import './assets/c ...
- vue 编程式导航
// 命名的路由(这里的name为路由中定义的name名称) this.$router.push({ name: 'user', params: { userId: '123' }}) // 带查询参 ...
- VueRouter爬坑第四篇-命名路由、编程式导航
VueRouter系列的文章示例编写时,项目是使用vue-cli脚手架搭建. 项目搭建的步骤和项目目录专门写了一篇文章:点击这里进行传送 后续VueRouter系列的文章的示例编写均基于该项目环境. ...
- vue动态路由传值以及get传值及编程式导航
1.动态路由传值 1.配置路由处 { path: '/content/:id', component: Content }, // 动态路由 2.对应页面传值 <router-link :to= ...
随机推荐
- codeforce 985A Chess Placing(暴力)
Chess Placing time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- ubuntu 14.04使用root登陆出现错误“Error found when loading /root/.profile”解决
在刚修改完root权限自动登录后,发现开机出现以下提示: Error found when loading /root/.profile stdin:is not a tty ----........ ...
- jquery嵌套后会触发2次点击事件, jquery的unbind就是卸载这个点击事件的.
$("#diva").click(function(){ $("#divb").unbind("click").click(function ...
- 自定义inputformat和outputformat
1. 自定义inputFormat 1.1 需求 无论hdfs还是mapreduce,对于小文件都有损效率,实践中,又难免面临处理大量小文件的场景,此时,就需要有相应解决方案 1.2 分析 小文件的优 ...
- MongoDB安全加固方案,防止数据泄露被勒索
早上起来,发现生产数据库被删了,留下一个数据库名叫“PLEASE_READ”,里面内容如下: "Info" : "Your DB is Backed up at our ...
- beijing
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<graphics.h> ...
- Catch That Cow(bfs)
Description Farmer John has been informed of the location of a fugitive cow and wants to catch her i ...
- ora-28547:连接服务器失败,可能是 Oracle Net 管理失败
检查如下: 监听程序的配置文件 发现多了 (PROGRAM = extproc) 去掉后如下: # listener.ora Network Configuration \dbhome_1\netwo ...
- hdu3530 Subsequence
题意:There is a sequence of integers. Your task is to find the longest subsequence that satisfies the ...
- 值得一做》关于数学与递推 BZOJ1002 (BZOJ第一页计划)(normal+)
什么都不说先甩题目 Description 轮状病毒有很多变种,所有轮状病毒的变种都是从一个轮状基产生的.一个N轮状基由圆环上N个不同的基原子和圆心处一个核原子构成的,2个原子之间的边表示这2个原子之 ...