vue2.0学习之路由
下载vue-router: cnpm install vue-router --save
router/main.js
/*引入所需要的组件*/
import VueRouter from 'vue-router';
import about from "compontents/about.vue"
import news from "compontents/news.vue"
import Router from 'vue-router'
import VueResource from 'vue-resource'; Vue.use(VueRouter);
Vue.use(VueResource);
Vue.use(Router); const routes = [ //这里是routes,没有r
{ path: '/goods', component: goods },
{ path: '/ratings', component: ratings },
{ path: '/seller', component: seller }
];
const router = new VueRouter({
routes,
linkActiveClass:'active'
});
router.push('/goods'); new Vue({
el:'#app',
router,
template:'<App/>',
components: { App }
})
compontents/about.vue 与compontents/news.vue 一样
<template>
<div>
我是关于我们/我是新闻
</div>
</template> <script>
export default { }
</script>
将about.vue和news.vue链接起来
<template>
<div id="app">
<div class="tab">
<div class="tab-item">
<router-link to="/about">关于</router-link>
</div>
<div class="tab-item">
<router-link to="/news">新闻</router-link>
</div>
</div>
<div>
<router-view></router-view>
</div>
</div>
</template>
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 ...
- Vue2.0中的路由配置
Vue2.0较Vue1.0,路由有了较大改变.看一下Vue2.0中的路由如何配置: 步骤一: 在main.js文件中引入相关模块以及组件及实例化vue对象配置选项路由及渲染App组件 默认设置如下: ...
- VUE2.0学习总结
摘要: 年后公司项目开始上vue2.0,自己对学习进行了总结,希望对大家有帮助! VUE2.0学习 vue介绍 vue是什么? https://vuefe.cn/guide vue也是一个数据驱动框架 ...
- Vue2.0学习--Vue数据通信详解
一.前言 组件是 vue.js最强大的功能之一,而组件实例的作用域是相互独立的,这就意味着不同组件之间的数据无法相互引用.组件间如何传递数据就显得至关重要.本文尽可能罗列出一些常见的数据传递方式,如p ...
- vue2.0学习教程
十分钟上手-搭建vue开发环境(新手教程)https://www.jianshu.com/p/0c6678671635 如何在本地运行查看github上的开源项目https://www.jianshu ...
- Vue2.0学习笔记一 :各种表达式
#,过滤器 #,在Vue2.x中,过滤器只能在mustache绑定中使用,为了在指令帮定中实现同样的行为,你应该使用计算属性: #,过滤器可以串联 {{ message | filterA | ...
- vue2.0学习(二)
1.关于模板渲染,当需要渲染多个元素时可以 <ul> <template v-for="item in items"> <li>{{ item. ...
- vue2.0里的路由钩子
路由钩子 在某些情况下,当路由跳转前或跳转后.进入.离开某一个路由前.后,需要做某些操作,就可以使用路由钩子来监听路由的变化 全局路由钩子: router.beforeEach((to, from, ...
随机推荐
- maven工具引入lib下的jar文件
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot ...
- codeforces 596 C. p-binary
题意:给你一个n和一个p,让你用 (2k+p)进制来表示n,找出用最少的(2k+p)来表示n. 分析:首先我们看到2k,首先下想到二进制,我们可以我们列出式子,也就是 (2x1 + p)+(2x2 + ...
- 期末项目之 Json文件
Github上的json文件: https://raw.githubusercontent.com/color-me/first/master/b
- .net APP接口
编写APP接口首先要搭建测试环境,在实际开发中APP对于大多数公司来说都是选择外包,并不是公司内部人员负责,遇到事情不可能时时进行沟通和交流,也不能写每一个接口都要双方及时确认.个人经历是双方确认AP ...
- PAT Advanced 1110 Complete Binary Tree (25) [完全⼆叉树]
题目 Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each ...
- JAVA课程设计——俄罗斯方块(团队)
1.团队介绍 1.1 团名:终于可以回家了嗷嗷嗷 1.2 团员介绍 2.参考来源 https://www.jb51.net/article/142716.htm 3.项目git地址 https://g ...
- Coursera机器学习——Recommender System测验
第一题本应该是基础题,考察Cost Function不同形式的表示方法,但却难住了我,说明基本概念掌握不够到位. 1. 在求和的部分,有两种可能,一种是(i,j)同时求和,即∑(i,j):r(i,j) ...
- 苹果智能AR挡风玻璃靠谱吗?
在过去十年,外界给苹果的形象一直是"伟大的硬件公司",他们的产品在外观方面往往比内涵更加引人注目,兼具娱乐性和艺术性, iPhone/iPad/iPod莫不如此,所以,当坊间传闻苹 ...
- 洛谷 P2871 [USACO07DEC]手链Charm Bracelet && 01背包模板
题目传送门 解题思路: 一维解01背包,突然发现博客里没有01背包的板子,补上 AC代码: #include<cstdio> #include<iostream> using ...
- Dynamics CRM - 利用 JavaScript 打开指定 entity 的新建窗口并传递需要的参数
由于业务逻辑需要,需要从某个 Entity 的 Record 中弹出其他 Entity 的创建窗口,并将当前 Entity 中的某些值传递到新打开的窗口中,具体的 JS 代码如下: //定义一个参数对 ...