app.vue
<!-- 模板 html-->
<template>
<div id="app">
{{title}}
<users></users>
</div>
</template>
<!-- 行为 -->
<script>
// 局部注册
import Users from './components/Users.vue'
export default {
name:'app',
// 写属性
data(){
return{
title:'hello'
}
},
// 局部注册
components:{
"users":Users
}
}
</script>
<!-- 样式 -->
<style>
</style>
users.vue
<template>
<div class="users">
<ul>
<li v-for="user in users">
{{user}}
</li>
</ul>
</div>
</template>
<script>
export default {
name: 'users',
data(){
return{
users:["1","2","3"]
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
main.js
import Vue from 'vue'
import App from './App.vue'
// 全局注册
// import Users from './components/Users.vue'
Vue.config.productionTip = false
// 全局注册
// Vue.component("users",Users);
new Vue({
render: h => h(App),
}).$mount('#app')