前端学习(2173):动态路由的跳转

app.vue

<template><div id="app"><router-link to="/home">首页</router-link><router-link to="/about">关于</router-link><router-link v-bind:to="'/user/'+userId">用户</router-link><router-view></router-view></div>
</template><script>
export default {name: 'App',data(){return{userId:'userId'}},methods:{}
}
</script><style></style>

 about.vue

<template>
<div>
<h2>
我是about
</h2>
<p>我是首页内容</p>
</div>
</template><script>
export default{name:"Home"
}
</script><style scoped></style>

User.vue

<template>
<div>
<h2>
我是user
</h2>
<p>我是首页内容</p>
<h2>{{userId}}</h2>
</div>
</template><script>
export default{name:"User",computed:{userId(){return this.$route.params.userId.abc}}
}
</script><style scoped></style>

index.js

import VueRouter from 'vue-router'
import Vue from 'vue'
import Home from '../components/Home'
import About from '../components/About'
import User from '../components/User'
Vue.use(VueRouter)const routes = [{path: '/',redirect: '/home'}, {path: '/home',component: Home},{path: '/about',component: About},{path: '/user/:userId',component: User},]//安装插件
const router = new VueRouter({//配置之间的关系routes,mode: 'history',linkActiveClass: 'active'
})export default router

运行结果

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/417700.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

前端测试框架 jasmine 的使用

最近的项目在使用AngulaJs,对JS代码的测试问题就摆在了面前。通过对比我们选择了 Karma jasmine ,使用 Jasmine做单元测试 &#xff0c;Karma 自动化完成&#xff0c;当然了如果使用 Karma jasmine 前提是必须安装 Nodejs。 安装好 Nodejs &#xff0c;使用 npm 安装好必要…

(HDU)1019 --Least Common Multiple(最小公倍数)

描述 一组正整数的最小公倍数&#xff08;LCM&#xff09;是可以被集合中所有数字整除的最小正整数。 例如&#xff0c;5,7和15的LCM为105。输入 输入将包含多个问题实例。 输入的第一行将包含指明问题实例数量的单个整数。 每个实例将由形式为m n1 n2 n3 ... nm的单行组成&…

如何将exe文件在linux下执行,如何在Linux系统下查找可执行文件

可执行文件是指可移植可执行的文件&#xff0c;用于程序的执行&#xff0c;那么Linux下要如何查找可执行文件呢&#xff1f;下面小编就给大家介绍下Linux中查找可执行文件的方法&#xff0c;一起来了解下吧。linux下查找可执行文件ls -F|grep “*”这样就可以了&#xff01;ls …

前端学习(2176):vue-router的路由的嵌套使用

app.vue <template><div id"app"><router-link to"/home">首页</router-link><router-link to"/about">关于</router-link><router-link v-bind:to"/user/userId">用户</router-link&g…

前端学习(2177):vue-router得参数传递

app.vue <template><div id"app"><router-link to"/home">首页</router-link><router-link to"/about">关于</router-link><router-link v-bind:to"/user/userId">用户</router-link&g…

前端学习(2178):vue-router得参数传递二

app.vue <template><div id"app"><router-link to"/home">首页</router-link><router-link to"/about">关于</router-link><button click"userClick">用户</button><button clic…

linux系统登陆问题,Linux之登陆问题

今天早上在使用Linux的时候进入终端输入startx&#xff0c;然后退出图形界面&#xff0c;进入了命令模式&#xff0c;可能是Ubuntu 14.04的问题&#xff0c;不知怎么就没有响应&#xff0c;我就强行重启了一下操作系统&#xff0c;然后进去发现在使用管理员账号登录时一直是重复…

前端学习(2180):vue-router全局导航守卫

app.vue <template><div id"app"><router-link to"/home">首页</router-link><router-link to"/about">关于</router-link><button click"userClick">用户</button><button clic…

(HDU)1058 --Humble Numbers( 丑数)

题目链接&#xff1a;http://vjudge.net/problem/HDU-1058 这题有点难度&#xff0c;自己写了半天依旧TLE&#xff0c;参考了其他人的博客。 http://blog.csdn.net/pythonfx/article/details/7292835 http://blog.csdn.net/x_iya/article/details/8774087 第二个人的博客用的是…

linux线程引起jvm崩溃,JVM宕机分析

1、可以引发JVM崩溃的常见缘由有&#xff1a;linux线程阻塞数据库CPU 使用率太高服务器JVM Crash工具堆内存不足google类装载spaJava虚拟机自身的Bug操作系统JDK与服务器(CPU、内存、操做系统)的兼容性.net内存溢出插件2、日志文件hs_err_pid.log&#xff0c;致命错误出现的时候…

ie9 Flash内容无法显示

Flash 插件(Shockwave Flash Object)启用&#xff1a; 在IE9页面右上角单击设置按钮&#xff0c;打开“管理加载项”。 查看一下 Shockwave Flash Object 的状态。如果被真被禁用了&#xff0c;将其选中&#xff0c;然后右击&#xff0c;选择“启用”。 ActiveX 筛选关闭&#…

02 检索数据

1.SELECT语句 从一个表或多个表中检索信息 2.检索单个列 输入&#xff1a; SELECT prod_name FROM Products; 输出&#xff1a; 没有过滤&#xff0c;也没有排序&#xff0c;输出数据顺序可能不同。 3.检索多个列 输入&#xff1a; SELECT prod_id, prod_name, prod_price F…

linux登录界面主题,Ubuntu 12.10登录界面主题:Butterfly

一款Ubuntu 12.10登录界面主题&#xff1a;Butterfly。A green MDM theme with faces for 4:3 aspect ratio screen resolutions such as 1024x768, 1280x960 or 1600x1200.Replace background.jpg with background_1280x1024.jpg for SXGA monitors.License RestoredThis MDM …

前端学习(2183):tabber--基本架构的构建

app.vue <template><div id"app"><div id"tab"><div class"tab-bar-item">首页</div><div class"tab-bar-item">分类</div><div class"tab-bar-item">购物车</div>…

拦截器 过滤器 监听器 的区别

面试的时候突然被问了这么个问题 本来知道点啥的 脑子一热 啥也没说出来总结一下 以下内容均摘自网络 但是 读完之后 应该会对它们有更清晰的认识。1.1 什么是拦截器&#xff1a; 拦截器&#xff0c;在AOP&#xff08;Aspect-Oriented Programming&#xff09;中用于在某…