vue2.0 路由知识一(路由的创建的全过程)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="../vue2.2.js"></script>
<script src="../vue-router2.1.js"></script>
</head>
<body>
<div id="app">
<p>
<!--通过to属性指定链接-->
<!--<router-link>默认会被渲染成一个<a>标签-->
<router-link to="/home" tag="li">Home</router-link>
<router-link to="/about">About</router-link>
<hr/>
<!--<router-link :to="{path:'home'}">Home</router-link>
<router-link :to="'about'" tag="li">About</router-link>-->
</p> <!--路由出口,将路由匹配的组件渲染到这里-->
<!--将自动设置class属性值 .router-link-active-->
<router-view></router-view>
</div> <script>
//1.定义组件
const Home = {
template:"<div><h1>Home</h1><p>Hello,vue router!</p></div>"
} const About = {
template:"<div><h1>About</h1><p>这是关于vue-router</p></div>"
} //2.定义路由 (每个路由应该映射一个组件)
const routes = [{
path:"/home",
component:Home
},{
path:"/about",
component:About
},{
path:"/",
redirect:"/home"
/*component:Home*/
},{
path:"*",
redirect:"/home"//重定向
}
] //3.创建router实例 ,然后传‘routes’ 配置
const router = new VueRouter({
linkActiveClass:'active',
/*mode:"history",*/
routes // 相当于 routes:routes
}) //4.创建和挂载根实例,从而让整个应用都有路由功能
const vm = new Vue({
router //相当于 router:router
}).$mount("#app") </script>
</body>
</html>
vue2.0 路由知识一(路由的创建的全过程)的更多相关文章
- vue2.0学习笔记之路由(二)路由嵌套+动画
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- vue2.0学习笔记之路由(二)路由嵌套
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 路由知识 静态路由 rip eigrp ospf
第1章 路由选择原理 1.1 几个概念 1.1.1 被动路由协议 用来在路由之间传递用户信息 1.1.2 主动路由协议 用于维护路由器的路由表 R2#show ip route Codes: C - ...
- vue2.0 vue-cli项目中路由之间的参数传递
1.首先配置路由, import Vue from 'vue' import Router from 'vue-router' Vue.use(Router) export default new R ...
- vue2.0基础知识,及webpack中vue的使用
## 基础指令 ## [v-cloak]{ Display:none; } <p v-cloak>xx{{msg}}xx</p> //解决闪烁问 ...
- vue2.0 之 douban (三)创建header组件
1.分析 首页的header背景是绿色的,并且有一个搜索框,其他页面都是灰色的背景,在header的左侧,是一个返回按钮,右侧,有分享或者评论等图标,中间就是header的标题.我们先不做有搜索框的h ...
- vue2.0 之 douban (四)创建Swipe图片轮播组件
swiper中文文档:http://www.swiper.com.cn 1.我们在components文件夹里创建一个swipe组件,将需要用到的js以及css文件复制到assets/lib文件夹下, ...
- vue2.0 之 douban (二)创建自定义组件tabbar
1.大体布局 这个组件分为两部分:第一个是组件的外层容器,第二个是组件的子容器item,子组件里面又分为图片和文字组合.子组件有2个状态,一个默认灰色的状态,一个选中状态,我们来实现一下这个组件的布局 ...
- vue2.0 之 douban (五)创建cell,media-cell组件
1.组件cell 这里的cell分为三种样式,左侧带图标,不带图标,以及左侧带竖线的cell. 每一个组件都有一个底部边框: 这里我们采用了移动端1px像素问题的解决方法:父级元素设置相对定位,构建1 ...
随机推荐
- tcp state
[root@hadoop1 log]# netstatActive Internet connections (w/o servers)Proto Recv-Q Send-Q Local Addres ...
- mongodb10---分片
分片:数据非常大,把不同段的数据拆了,1-1000000放在节点1,1000000-2000000放在节点2,200000-300000放在节点上.把不同的数据放在不同的服务器叫shard分片. 请求 ...
- Android ConstraintLayout的基本使用
升级Android studio到2.3版本之后,发现新建Activity或fragment时,xml布局默认布局由RelativeLayout更改为ConstraintLayout了,既然已经推荐使 ...
- java 泛型的理解与应用
为什么使用泛型? 举个例子: public class GenericTest { public static void main(String[] args) { List list = new A ...
- Ural2102:Michael and Cryptography(数论&素数)
The hacker Michael develops breakthrough password manager, which is called KEK (Keeper of Encrypted ...
- zoj 3861(dfs)
Valid Pattern Lock Time Limit: 2 Seconds Memory Limit: 65536 KB Pattern lock security is genera ...
- 二、Log4j基本使用方法
转自:https://blog.csdn.net/luohai859/article/details/52250807 Log4j由三个重要的组件构成:日志信息的优先级,日志信息的输出目的地,日志信息 ...
- Linux Gcc编译错误(转载)
转自:http://www.linuxidc.com/Linux/2012-01/52153.htm Linux系统下的c编程与Windows有所不同,如果你在用gcc编译代码的时候提示‘for’ l ...
- HDU2604:Queuing(矩阵快速幂+递推)
传送门 题意 长为len的字符串只由'f','m'构成,有2^len种情况,问在其中不包含'fmf','fff'的字符串有多少个,此处将队列换成字符串 分析 矩阵快速幂写的比较崩,手生了,多练! 用f ...
- POJ2823:Sliding Window
传送门 题意 有一个数列a,要求你求数列b和c,b[i]是a[i]-a[i+w-1]中的最小值,c[i]是最大值.如果a是1,3,-1,-3,5,3,6,7,则b为-1,-3,-3,-3,3,3,c为 ...