vue-router 인스턴스

2406 단어 경로HTML+CSSvue
vue 라우팅 소개


	
		
		<script src="https://unpkg.com/vue/dist/vue.js"/>
		<script src="https://unpkg.com/vue-router/dist/vue-router.js"/>
		<style>	
		#app{
			position: absolute;	
				}	
		router-link {position: absolute;	 }
		.dropbtn {
			display: inline-block;
			color: white;
			text-align: center;
			padding: 16px 20px;
			font-size: 30px;
			text-decoration: none;
		}
		li a:hover, .dropdown:hover .dropbtn{
			background-color: blue;
		}
		.dropdown{
			display: inline-block;
		}
		.dropdown-content {
			display: none;
			position: absolute;
			background-color: #f9f9f9;
			min-width: 160px;
		}
		.dropdown-content a{
			color: black;
			padding: 12px 16px;
			text-decoration: none;
	   		display: block;
		}
				
		.dropdown:hover .dropdown-content {
			display: block;
		}
		
	</style>
		
	

	<div id="app">
		<!--    router-link      -->
		<!--     `to`       -->
		<!-- <router-link>         "<a>"  -->
		<router-link to="/left">Left</router-link>
		<router-link to="/right">Right</router-link>	
		
		<!--                -->
		<router-view/>
	</div>
	
	

		<script>
	
			const Left = {template: '<div class="dropdown"><a href="#new" class="dropbtn">  </a><div class="dropdown-content"><a href="#">    </a><a href="#">    </a></div></div>',
				data: function(){
					return {
						msg: 'How to use vue-router!'}
				}
			}			
			var Right = Vue.extend({
    			template: '	<div class="dropdown"><a href="#new" class="dropbtn">  </a><div class="dropdown-content"><a href="#">    </a><a href="#">    </a></div></div>'
			})
			 				
			const routes =[
				{ path: '/left', component: Left },
  				{ path: '/right', component: Right }	
			]
			var router = new VueRouter({
				routes
				})

			
			var app = new Vue({
				router
				}).$mount('#app')
			
		</script>

</code></pre> 
  <p> </p> 
 </div> 
</div>
                            </div>
                        </div>

좋은 웹페이지 즐겨찾기