笔记
一般把第三方库或样式放在一个公共的位置。
重要源码
App.vue
<template>
<!-- 来源 04_静态页面\2_users_page\index.html -->
<div class="container">
<Search></Search>
<List></List>
</div>
</template>
<script>
//1. 引入组件
import Search from './components/Search.vue'
import List from './components/List.vue'
//引入 axios
//import axios from 'axios'
//引入 样式
//通过 import 引入,脚手架会做严格的检查。只要发现不存在资源,就会提示错误。
// 例如:
// 提示错误: Module not found: Error: Can't resolve '../fonts/glyphicons-halflings-regular.svg'
//该文件大概会用到 8种字体。 如果暂时用不到,不建议这种引入。
//import './assets/css/bootstrap.css'
//建议:将第三方样式放到 public\index.html引入, 同时将第三方样式放到 public
export default {
//2. 注册组件
components: { Search, List },
name:'App',
}
</script>
<style>
</style>components\Search.vue
<template>
<!-- 头部搜索 -->
<section class="jumbotron">
<h3 class="jumbotron-heading">Search Github Users</h3>
<div>
<input type="text" placeholder="enter the name you search"/> <button>Search</button>
</div>
</section>
</template>
<script>
export default {
name:'SearchVue'
}
</script>
<style>
</style>components\List.vue
<template>
<!-- list区 -->
<div class="row">
<div class="card">
<a href="https://github.com/xxxxxx" target="_blank">
<img src="https://v2.cn.vuejs.org/images/logo.svg" style='width: 100px'/>
</a>
<p class="card-text">xxxxxx</p>
</div>
<div class="card">
<a href="https://github.com/xxxxxx" target="_blank">
<img src="https://v2.cn.vuejs.org/images/logo.svg" style='width: 100px'/>
</a>
<p class="card-text">xxxxxx</p>
</div>
<div class="card">
<a href="https://github.com/xxxxxx" target="_blank">
<img src="https://v2.cn.vuejs.org/images/logo.svg" style='width: 100px'/>
</a>
<p class="card-text">xxxxxx</p>
</div>
<div class="card">
<a href="https://github.com/xxxxxx" target="_blank">
<img src="https://v2.cn.vuejs.org/images/logo.svg" style='width: 100px'/>
</a>
<p class="card-text">xxxxxx</p>
</div>
<div class="card">
<a href="https://github.com/xxxxxx" target="_blank">
<img src="https://v2.cn.vuejs.org/images/logo.svg" style='width: 100px'/>
</a>
<p class="card-text">xxxxxx</p>
</div>
</div>
</template>
<script>
export default {
name:'ListVue'
}
</script>
<style scoped>
.album {
min-height: 50rem; /* Can be removed; just added for demo purposes */
padding-top: 3rem;
padding-bottom: 3rem;
background-color: #f7f7f7;
}
.card {
float: left;
width: 33.333%;
padding: .75rem;
margin-bottom: 2rem;
border: 1px solid #efefef;
text-align: center;
}
.card > img {
margin-bottom: .75rem;
border-radius: 100px;
}
.card-text {
font-size: 85%;
}
</style>
