<p>代码错误已修正,以下是修正后的代码:</p>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="../vue.js"></script>
		<script src="../vue-router.js"></script>
	</head>
	<body>
<pre><code>	&lt;style&gt;
		ul,li,h1{
			padding: 0;
			margin: 0;
			list-style: none;
		}
		#app{
			width: 100%;
			display: flex;
			flex-direction: row;
		}
		ul{
			width: 200px;
			flex-direction: column;
			color: #fff;
		}
		li{
			flex: 1;
			background: #000;
			margin: 5px auto;
			text-align: center;
			line-height: 30px;
		}
		.about-detail{
			flex: 1;
			margin-left: 30px;
		}
		.about-detail h1{
			font-size: 24px;
			color: blue;
		}
	&lt;/style&gt;
	
	&lt;div id=&quot;app&quot;&gt;
		&lt;ul&gt;
			&lt;router-link to=&quot;/about&quot; tag=&quot;li&quot;&gt;关于公司&lt;/router-link&gt;
			&lt;router-link to=&quot;/contact&quot; tag=&quot;li&quot;&gt;联系我们&lt;/router-link&gt;
		&lt;/ul&gt;
		&lt;router-view&gt;&lt;/router-view&gt;
	&lt;/div&gt;
	
	&lt;template id=&quot;about-tmp&quot;&gt;
		&lt;div class=&quot;about-detail&quot;&gt;
			&lt;h1&gt;北京科技有限公司简介&lt;/h1&gt;
			
			&lt;router-link to=&quot;/about/detail&quot;&gt;公司简介&lt;/router-link&gt;
			&lt;router-link to=&quot;/about/governance&quot;&gt;公司治理&lt;/router-link&gt;
			&lt;router-view&gt;&lt;/router-view&gt;
		&lt;/div&gt;
	&lt;/template&gt;
	
	&lt;template id=&quot;contact-tmp&quot;&gt;
		&lt;div class=&quot;about-detail&quot;&gt;
			&lt;h1&gt;联系我们&lt;/h1&gt;
			&lt;p&gt;公司位于北京市海淀区中关村科技园内,主营业务包括餐饮娱乐,服装设计等&lt;/p&gt;
		&lt;/div&gt;
	&lt;/template&gt;
	
	&lt;script&gt;
		 var about={template:'#about-tmp'}
		 var contact={template:'#contact-tmp'}
		 
		 var detail={
		 	template:'&lt;p&gt;xx是全球领先&lt;/p&gt;'
		 }
		 var governance={
		 	template:'&lt;p&gt;公司坚持与客户为中心,以奋斗着为本&lt;/p&gt;'
		 }
		 
		 var router = new VueRouter({
		 	routes:[
		 		{path:'/',redirect:'/about'},
		 		{
		 			path:'/about',
		 			component:about,
		 			children:[
		 				{path:'detail',component:detail},
		 				{path:'governance',component:governance}
		 			]
		 		},
		 		{path:'/contact',component:contact}
		 	]
		 })
		 
		 var vm=new Vue({
		 	el:'#app',
		 	router:router
		 })
	&lt;/script&gt;
&lt;/body&gt;
</code></pre>
</html
!DOCTYPE htmlhtml	head		meta charset=UTF-8		titletitle		script src=vuejsscript		script src=vue-routerjsscript	head	body				style			ullih1				padding 0;				margin 0;				list-style none;						#app				wi

原文地址: https://www.cveoy.top/t/topic/e1X2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录