zoukankan      html  css  js  c++  java
  • vue-创建路由

    <body>
    		<div id="app">
    			<h1>Hello App!</h1>
    			<p>
    				<!-- 使用 router-link 组件来导航. -->
    				<!-- 通过传入 `to` 属性指定链接. -->
    				<!-- <router-link> 默认会被渲染成一个 `<a>` 标签 -->
    				<router-link to="/foo">Go to one</router-link>
    				<router-link to="/bar">Go to two</router-link>
    				<router-link to="/one">Go to three</router-link>
    			</p>
    			<!-- 路由出口 -->
    			<!-- 路由匹配到的组件将渲染在这里 -->
    			<router-view></router-view>
    		</div>
    		<script src="https://unpkg.com/vue/dist/vue.js"></script>
    		<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
    		<script type="text/javascript">
    			// 1. 定义(路由)组件。
    			// 可以从其他文件 import 进来
    			const Foo = { template: '<div class="one">我是one</div>' }
    			const Bar = { template: '<div class="two">我是two</div>' }
    			const One = { template: '<div class="three">我是three</div>' }
    			// 2. 定义路由
    			// 每个路由应该映射一个组件。 其中"component" 可以是
    			// 通过 Vue.extend() 创建的组件构造器,
    			// 或者,只是一个组件配置对象。
    	
    			const routes = [
    				{ path: '/foo', component: Foo },
    				{ path: '/bar', component: Bar },
    				{ path: '/one', component: One }
    			]
    			// 3. 创建 router 实例,然后传 `routes` 配置
    			// 你还可以传别的配置参数, 不过先这么简单着吧。
    			const router = new VueRouter({
    				routes // (缩写)相当于 routes: routes
    			})
    			// 4. 创建和挂载根实例。
    			// 记得要通过 router 配置参数注入路由,
    			// 从而让整个应用都有路由功能
    			const app = new Vue({
    				router
    			}).$mount('#app')
    
    			// 现在,应用已经启动了!
    		</script>
    	</body>
    

      

  • 相关阅读:
    windows 安装 ELK(Elasticsearch,Logstash,kibana)
    NSSM 将程序封装成服务软件
    面试-双向链表
    mySql 事务,游标以及循环
    SQL 事务
    C# Windows 服务
    MVC 中ajax 调用Webservice 或WCF 问题
    js prototype
    计算一个数等于其它数相加的所有可能 如: 5 =1+4 ,1+3+1,2+3,2+2+1,1+1+1+1+1,1+1+1+2
    冒泡排序,选择排序,快速排序
  • 原文地址:https://www.cnblogs.com/LWJ-booke/p/7363850.html
Copyright © 2011-2022 走看看