1
所以我安裝了最新的Vue CLI並設置了一個項目。我熟悉Vue的概念,但我需要結構的幫助。有人可以指導我如何創建一個可用於所有頁面的導航欄,幷包含頁面的vue-router鏈接?我的第一個想法是製作一個組件Navbar.vue
,並以某種方式將它放到App.vue中,以便它在任何<router-view></router-view>
之前呈現。這是做到這一點的正確方法嗎?我會試着把它放在index.html裏面嗎?我很困惑如何做到這一點。我正在使用CSS的bootstrap。Vue CLI插入導航欄
的index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>foo.ca</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
App.vue:
<template>
<div id="app">
<!--<img src="./assets/logo.png">-->
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'app'
}
</script>