2020
10-09
10-09
Vue 实现创建全局组件,并且使用Vue.use() 载入方式
自定义vue组件,一般是局部引用的方式载入,使用的时候,在应用的组件中使用importmoduleNamefrom‘module'导入,在components中注册<template><divclass="app-NewsInfo"><h3>{{info.title}}</h3><!--新闻评论子组件。--><comment:id="id"></comment></div></template><script>importcommentfrom"../sub/comment.vue";exportdefault{data(){return{info:{},id:this.$route.query.id};},methods:{...
继续阅读 >
1、组件声明<!--全局组件模板father模板--><templateid="father"><div><h3>这是{{name}}</h1><div><p>这是{{data}}</p></div></div></template>varFATHER={template:"#father",data:function(){return{name:"一个全局组件-模板-",data:"数据:18892087118"}}};2、组件注册Vue.component('father',FATHER);3、组件挂载<h5>全局组件1</h5><father></father...