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, ...
随机推荐
- 2020.2.21一些python总结
#字符串前面加r可以防止字符串转义 \也可以防止字符串转义#三引号可以实现输入多行文本#range(start,end,step)#列表 append添加一个元素到末尾 extend 添加一个素组到末 ...
- kali由wifi握手包破解密码&&gnuplot使用
1.kali密码破解(WiFi握手包) cap包密码破解,aircrack-ng wifi.cap -w psw.txt(你的字典文件) 2.画图工具gnuplot 1.txt中保存的是坐标,形式为: ...
- 使用plantuml插件
安装 https://github.com/jvantuyl/sublime_diagram_plugin 安装依赖 brew install graphviz 把sublime_diagram_pl ...
- one_day_one_linuxCmd---netstat命令
<坚持每天学习一个 linux 命令,今天我们来学习 netstat 命令> 前言:netstat 命令用于显示各种网络相关信息,如网络连接,路由表,接口状态等,还可以很方便查看本地机器上 ...
- Thread--synchronized&volatile
- Spring Data JPA简单查询接口方法速查
下表针对于简单查询,即JpaRepository接口(继承了CrudRepository接口.PagingAndSortingRepository接口)中的可访问方法进行整理.(1)先按照功能进行分类 ...
- Python说文解字_详解元类
1.深入理解一切接对象: 1.1 什么是类和对象? 首先明白元类之前要明白什么叫做类.类是面向对象object oriented programming的重要概念.在面向对象中类和对象是最基本的两个概 ...
- Cracking Digital VLSI Verification Interview 第四章
目录 Hardware Description Languages Verilog SystemVerilog 对Cracking Digital VLSI Verification Intervie ...
- 配置Action
配置Action 实现了Action类后,就可以在struts.xml中配置该Action类了.配置Action就是让Struts2 知道哪个Action处理哪个请求,也就是完成用户请求和Action ...
- MySQL--mysqldump(数据导出工具)
mysqldump 客户端工具用来备份数据库或在不同数据库之间进行数据迁移.备份内容包含创建表或装载表的 SQL 语句.mysqldump 目前是 MySQL 中最常用的备份工具. 有 3 种方式来调 ...