第一步先创建脚手架,npm create github(名字自取,影响不大)然后将APP组件清空,在components文件夹中创建search和list组件。
APP.vue
在APP中引入并使用
<template>
<div class="container">
<search />
<list />
</div>
</template>
<script>
// 引入组件
import search from './components/search.vue'
import list from './components/list.vue'
export default {
name: 'App',
// 注册组件
components: {
search,
list
}
}
</script>
在main.js中注册全局事件总线,方便后面使用,将整个new vue修改
new Vue({
el:'#app',
render:h => h(App),
beforeCreate(){
Vue.prototype.$bus=this
}
})
list.vue
在list组件中,完成搜索展示
<templa