<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
padding: 0px;
margin: 0px;
}
.router-link-active{
color: #2aabd2;
}
li{
list-style: none;
float: left;
padding-left: 30px;
}
</style>
</head>
<body>
<div id='app'>
<!--//1.-->
<router-link to='/home'>首頁(yè)</router-link>
<router-link to='/detail'>詳情頁(yè)</router-link>
<!-- 盛放每個(gè)頁(yè)面對(duì)應(yīng)的內(nèi)容-->
<router-view></router-view>
</div>
<script src='js/vue.js'></script>
<script src='js/vue-router.js'></script>
<script src="js/axios.js"></script>
<script>
//2.創(chuàng)建組件
var Home={
template:`
<h1>楊夢(mèng)嬌</h1>
`
}
var Detail={
template:`
<div>
<h1>小摳逼</h1>
<ul>
<li>
<router-link to='/detail/zhuce'>注冊(cè)</router-link>
</li>
<li>
<router-link to='/detail/denglu'>登錄</router-link>
</li>
</ul>
<table border="1" cellspacing="0" width="800px">
<thead>
<tr>
<th>編號(hào)</th>
<th>名稱(chēng)</th>
<th>單價(jià)</th>
<th>數(shù)量</th>
<th>小計(jì)</th>
</tr>
</thead>
<tbody>
<tr v-for="w in funes">
<td>{{w.num}}</td>
<td>{{w.pname}}</td>
<td>{{w.price}}</td>
<td>{{w.count}}</td>
<td>{{w.sub}}</td>
</tr>
</tbody>
</table>
<router-view></router-view>
</div>
`,
data:function(){
return{
funes:null
}
},
mounted:function(){
var self=this;
axios({
method:'get',
url:'fruit.json'
}).then(function(resp){
self.funes=resp.data
}).catch(function(err){
})
}
}
var Zhuce={
template:`
<h4>這是注冊(cè)頁(yè)面</h4>
`
}
var Denglu={
template:`
<h4>這是登錄頁(yè)面</h4>
`
}
//3.配置路由
const routes=[
{path:'/',component:Home},
{path:'/home',component:Home},
{
path:'/detail',
component:Detail,
children:[
{path:'zhuce',component:Zhuce},
{path:'denglu',component:Denglu},
]
}
]
//4.創(chuàng)建一個(gè)路由實(shí)例
const router=new VueRouter({
routes:routes
})
//把路由掛在到vue實(shí)例上
new Vue({
el:'#app',
router:router
})
</script>
</body>
</html>
active
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 遇見(jiàn)的錯(cuò)誤: 第一次運(yùn)行報(bào)的錯(cuò)誤:error: No architectures to compile for (...
- 編譯工程的過(guò)程中莫名其妙的出現(xiàn)架構(gòu)的問(wèn)題,很是苦惱,不知道自己哪里犯下了什么錯(cuò)誤,終于在苦苦找尋之下,明白了是因?yàn)?..
- # yum -y install iptables iptables-services # vim/etc/sys...
- 朋友第一次參加相親,不知道該聊什么,想給對(duì)方帶一些小禮品增加好感度,問(wèn)小編有沒(méi)有什么建議給他。 我:帶一包糖去啊o...