index.js如果在router目录下,代表这个js文件只是路由使用

main.js中为全局,需要引入使用到的组件,一般vue中不用写东西
vue中el挂载哪个就哪个组件为根目录,
传值数据绑定的时候在组件(即app.vue之类的),必须返回data值,写data数据格式为:
export default {
name: 'App',//组件名字
data(){//固定格式,里面和data一样
return{
message: 'Welcome to Your Vue.js App'
}
}
}

路由:
APP.vue里面写
<router-link to="/">hello</router-link>
<router-link to="/news">news</router-link>
<router-link to="/about">about</router-link>

<script>
export default {
name: 'App',//组件名字
data(){//固定格式,里面和data一样
return{
message: 'Welcome to Your Vue.js App'
}
}
}

index.js里面写
import News from '@/components/News'
import About from '@/components/About'

routes: [
{
path: '/', //自定义类似id
name: 'HelloWorld',//组件名字,也可以不写
component: HelloWorld
},
{
path:'/news',
name:'News',
component:News
},{
path:'/about',
name:'About',
component:About
},
]
</script>

News.vue/Test.vue中
<template>
<div>
<h1>2</h1>

</div>
</template>

在哪用所需要的东西就在哪里声明
例如路由
index.js中:

import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import router from '@/components/router'
Vue.use(Router)

传输请求数据
main.js中
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(VueAxios,axios)

如果想让数据在别的页面中显示记得在index.js中引入组件

组件router.vue中
<template>
<div>
<pre>{{content}}</pre>
//自动解析并返回json数据格式,如果是span标签就是通栏显示
</div>
</template>
<script>
export default {
name:'router',
data(){
return{
content:''
}
},
//页面挂载完成之后执行的函数
mounted(){
this.axios.post("http://api.komavideo.com/news/list").then(body=>{
this.content=body.data;
})
}
}
</script>

vue路由(基于VScode开发)的更多相关文章

  1. .gitignore 标准模板 -适用于SpringBoot+Vue项目 -Idea+VSCode开发

    .gitignore 标准模板 -适用于SpringBoot+Vue项目 node_modules/ target/ !.mvn/wrapper/maven-wrapper.jar ### STS # ...

  2. 基于.NetCore开发博客项目 StarBlog - (2) 环境准备和创建项目

    系列文章 基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客? 基于.NetCore开发博客项目 StarBlog - (2) 环境准备和创建项目 ... 基于. ...

  3. 基于.NetCore开发博客项目 StarBlog - (3) 模型设计

    系列文章 基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客? 基于.NetCore开发博客项目 StarBlog - (2) 环境准备和创建项目 基于.NetC ...

  4. 循序渐进VUE+Element 前端应用开发(10)--- 基于vue-echarts处理各种图表展示

    在我们做应用系统的时候,往往都会涉及图表的展示,综合的图表展示能够给客户带来视觉的享受和数据直观体验,同时也是增强客户认同感的举措之一.基于图表的处理,我们一般往往都是利用对应第三方的图表组件,然后在 ...

  5. 【技术博客】基于vue的前端快速开发(工具篇)

    一.Vue教程 vue.js是一套构建用户界面的渐进式框架.vue采用自底向上增量开发的设计.vue的核心库只关心视图层,非常容易学习,非常容易与其它库和已有项目整合.vue完全有能力驱动采用单文件组 ...

  6. 用VSCode开发一个基于asp.net core 2.0/sql server linux(docker)/ng5/bs4的项目(1)

    最近使用vscode比较多. 学习了一下如何在mac上使用vscode开发asp.netcore项目. 这里是我写的关于vscode的一篇文章: https://www.cnblogs.com/cgz ...

  7. spring boot + vue + element-ui全栈开发入门——基于Electron桌面应用开发

     前言 Electron是由Github开发,用HTML,CSS和JavaScript来构建跨平台桌面应用程序的一个开源库. Electron通过将Chromium和Node.js合并到同一个运行时环 ...

  8. 基于Html5 Plus + Vue + Mui 移动App 开发(二)

    基于Html5 Plus + Vue + Mui 移动App 开发(二) 界面效果: 本页面采用Html5 Plus + Vue + Mui 开发移动界面,本页面实现: 1.下拉刷新.上拉获取更多功能 ...

  9. 用vscode开发vue应用[转]

    https://segmentfault.com/a/1190000019055976 现在用VSCode开发Vue.js应用几乎已经是前端的标配了,但很多时候我们看到的代码混乱不堪,作为一个前端工程 ...

随机推荐

  1. LC 609. Find Duplicate File in System

    Given a list of directory info including directory path, and all the files with contents in this dir ...

  2. to_datetime 以及 dt.days、dt.months

    Series类型的数据,经过 to_datetime 之后就可以用 pandas.Series.dt.day 和 pandas.Series.pd.month. import pandas as pd ...

  3. httpClient模仿Basic Auth

    httpclient代码调用如下: @GetMapping("loginTest") public String httpClientWithBasicAuth() { Strin ...

  4. ANSI C遍历二维数组指针地址

    #include <stdio.h> int main() { ][] = {,,,}; //等价于{{1,2},{3,4}}; ; i < ; i++) { ; j < ; ...

  5. 分布式架构-Redis 从入门到精通 完整案例 附源码

    导读 篇幅较长,干货十足,阅读需要花点时间,全部手打出来的字,难免出现错别字,敬请谅解.珍惜原创,转载请注明出处,谢谢~! NoSql介绍与Redis介绍 什么是Redis? Redis是用C语言开发 ...

  6. MaxScale中间件部署数据库读写分离

    操作系统:CentOS7 (Core) 数据库:MariaDB-10.2.6-linux-glibc_214-x86_64 MaxScale服务器:192.168.40.134 主服务器:192.16 ...

  7. Python面试简介及并行并发

    今天的分享内容大体如下: 一. 面试 1. 什么是面试 2. 优秀的面试 二. Python综述 1. Python设计哲学及版本变迁 2. Python发展现状及其他语言使用场景 3. GIL 4. ...

  8. [转载]Jupyter Notebook 的快捷键

    原文:http://blog.csdn.net/lawme/article/details/51034543 Jupyter Notebook 的快捷键 Jupyter Notebook 有两种键盘输 ...

  9. 【Linux开发】linux设备驱动归纳总结(四):2.进程调度的相关概念

    linux设备驱动归纳总结(四):2.进程调度的相关概念 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...

  10. 复杂json格式转化为javabean

    工具阿里巴巴的fastjson包 <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson --><dependenc ...