此篇内容为全局及局部引用

Main.js
import Users from './components/Users' //引入组件
Vue.component("users",Users) //注册组件

脚手架中局部注册组件
1、创建

Users.vue
---->dom
---->

<script>
export default {
name: 'users',
props : {
users02 : {
type : Array,
required : true
}
},
methods : {
deleteUser : function(){
this.users02.pop()
}
}
}
</script>

2、App.vue 中引入

<script>
import Users from './components/Users'
import Header from './components/Header'
import Footer from './components/Footer'

export default {
name: 'App',
data(){
return {
users :[ 
{name:"duan",position : "web开发",show : false},
{name:"duan",position : "web开发",show : false},
{name:"duan",position : "web开发",show : false},
{name:"duan",position : "web开发",show : false},
{name:"duan",position : "web开发",show : false}
],
title : "传递的是一个值 string number boolean"
}
},
methods :{
updateTitle(title04){
this.title = title04;
}
}
,
components : {
"users" : Users,
"app-header": Header,
"app-footer": Footer
}
}
</script>

3、在main.js组合

import Vue from 'vue'
import App from './App'

Vue.config.productionTip = false

//全局注册组件
// Vue.component("users",Users)

/* eslint-disable no-new */
new Vue({
el: '#app',
components: { App },
template: '<App/>'
})
暂无评论
shijiebei 365bet manbetx 188bet xinshui caipiao 95zz tongbaoyule beplay 88bifa 18luck betway bwin hg0088 aomenjinshayulecheng ca88 shenbotaiyangcheng vwin w88 weide