初篇 ==============================================================

1. 编写loading组件(components/Loading/index.vue)

<template>
<div>loading</div>
</template> <script>
export default {
name: 'loading'
}
</script>

2.注册为全局组件 (components/Loading/index.js)

import loading from './index.vue'
const loadingOp= {
install: (Vue) => {
Vue.component('loading', loading)
}
}
export default loadingOp

3.定义组件库(components/index.js)

import Model from './Model'
import Loading from './Loading'
export default {
Model,
Loading
}

4.开启全局使用此组件 (main.js)

import componetList from './components'
const { Model, Loading } = componetList
Vue.use(Model).use(Loading)

5. 使用组件

<template>
<loading></loading>
</template>
中篇 ==============================================================

1. 使用组件

1.新建一个plugins文件夹 
2.在文件夹中创建放置全局组件的文件components.js 
3.在components.js文件中引入所有要注册的全局组件 
4.在app.js根实例文件中,引入components.js

import eg from '../components/eg.vue'; export default (Vue)=>{ Vue.component("Eg",eg); }

vue 复习篇. 注册全局组件,和 组件库的更多相关文章

  1. Vue之组件及组件通信

    组件之全局组件 //注意:需要在Vue实例化之前注册全局组件,使用Vue.component("组件名",{ template:`组件模板` }) Vue.component(&q ...

  2. VUE注册全局组件和局部组件

    全局组件 第一步:在components文件夹下建立一个子文件Users.vue <template> <div class="users"> {{msg} ...

  3. vue 自动注册全局组件

    vue 自动注册全局组件 vue 注册全局组件的方式 const plugins = { install(Vue) { const requireComponent = require.context ...

  4. vue 注册全局组件

    注册全局组件有啥好处呢? 提高代码的复用性:哪里需要写哪里,贼方便,就写一个标签:减少代码量:可以再配合slot一起使用,咦~~,舒服 为了让整个项目的可读性,我创建一个文件统一存放全局组件 1.创建 ...

  5. vue 中注册全局组件

    1  全局注册组件 建一个 js 文件, 注册全局组件, 并且暴露出去 然后再在 main.js  中引入       在页面就可以直接使用了    2 全局注册过滤器 建立文件, 包含所有过滤器方法 ...

  6. Vue基础二之全局API、实例属性和全局配置,以及组件进阶(mixins)的详细教程(案列实现,详细图解,附源码)

    本篇文章主要是写Vue.directive().Vue.use()等常用全局API的使用,vm.$props.vm.$options.vm.$slots等实例属性的使用,以及Vue全局配置.组件的mi ...

  7. Webpack+vue2.0如何注册全局组件 (01)

    Part 1, 问题: webpack + vue2.0框架中,如何在入口js中注册组件? 就是在一个月以前,匆匆闯入vuejs这个社群,基本了解了vuejs的一些基础特性和语法.笔者兴致勃勃地开始想 ...

  8. vue.js中的全局组件和局部组件

    组件(Component)是 Vue.js 最强大的功能之一.组件可以扩展 HTML 元素,封装可重用的代码.在较高层面上,组件是自定义元素, Vue.js 的编译器为它添加特殊功能. 组件的使用有三 ...

  9. vue基础篇---vue组件

    vue模块第一篇,因为公司马上要用到这vue开发.早就想好好看看vue了.只有实际工作中用到才会进步最快.vue其他的简单指令就不多讲了,没啥意思,网上一大堆.看w3c就ok. 组件这个我个人感觉坑蛮 ...

随机推荐

  1. OC学习篇之---KVC和KVO操作

    前一篇文章我们介绍了OC中最常用的文件操作:http://blog.csdn.net/jiangwei0910410003/article/details/41875015,那么今天来看一下OC中的一 ...

  2. php 后台转发和重定向的区别及kohana框架当前url加参数方式

    1.重定向是浏览器行为,浏览器地址有变化:转发是后台服务器完成, url地址不变化. 2.kohana获取URL 当前url是http://soyoung.kohana.com/blog/add?id ...

  3. express框架总结

    1.express教程及api : http://www.runoob.com/nodejs/nodejs-express-framework.html 2.nodejs的express自动生成项目框 ...

  4. centos6编译安装php7

    https://www.cnblogs.com/wenwei-blog/p/6261637.html https://www.cnblogs.com/imzye/p/5109770.html cent ...

  5. BZOJ5484: [Usaco2018 Dec]Sort It Out

    5484: [Usaco2018 Dec]Sort It Out https://www.lydsy.com/JudgeOnline/problem.php?id=5484 Sol. 考虑没有在被喊叫 ...

  6. 75、python学习第一篇

    1.sys包下边的argv方法,从控制台获取数据 ''' Created on 2017年4月8日 @author: weizhen ''' import sys One = [" * &q ...

  7. Rust <0>:源代码组织,Cargo 入门

    Rust 源代码组织,使用配套的 Cargo 工具,其功能强大,程序员可摆脱 C/C++ 中需要自行维护 make.cmake 之类配置的工作量. 初始化一个项目: cargo new --bin h ...

  8. PAT甲级——A1141 PATRankingofInstitution

    After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...

  9. 力扣算法题—143ReorderList

    Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not mod ...

  10. leetcode python翻转字符串里的单词

    # Leetcode 151 翻转字符串里的单词### 题目描述给定一个字符串,逐个翻转字符串中的每个单词. **示例1:** 输入: "the sky is blue" 输出: ...