vue.2.0-自定义全局组件
App.vue
<template>
<div id="app">
<h3>welcome vue-loading</h3>
<Loading></Loading> <!--<Loading></Loading>是自定义组件-->
</div>
</template>
main.js
import Vue from 'vue'
import App from './App.vue' import Loading from './components/loading' //定义Loading,components、loading是一个文件夹,loading里面必须要index.js Vue.use(Loading) //use Loading new Vue({
el: '#app',
render: h => h(App)
})
index.js
import LoadingComponent from './Loading.vue'
const Loading = { //定义Loading
install: function(Vue) {//install是必须的
Vue.component('Loading', LoadingComponent)//定义一个组件
}
};
export default Loading
Loading.vue
<template>
<div class="loading-box">
{{msg}}
</div>
</template>
<script>
export default{
data(){
return {
msg:'Loading...^_^'
}
}
}
</script>
<style scoped>
.loading-box{
color: red;
font-size: 40px;
font-family: 微软雅黑;
text-shadow: 2px 2px 5px #000;
}
</style>
vue.2.0-自定义全局组件的更多相关文章
- vue.js2.0 自定义组件初体验
理解 组件(Component)是 Vue.js 最强大的功能之一.组件可以扩展 HTML 元素,封装可重用的代码.在较高层面上,组件是自定义元素, Vue.js 的编译器为它添加特殊功能.在有些情况 ...
- 07vue 自定义全局组件 通用流程
1.全局组件的目录 2.loading/index.js import LoadingComp from './Loaiding' const compName=LoadingComp.name // ...
- vue2 自定义全局组件(Loading加载效果)
vue2 自定义全局组件(Loading加载效果) github地址: https://github.com/ccyinghua/custom-global-component 一.构建项目 vue ...
- vue里在自定义的组件上定义的事件
事件分为原生事件和自定义事件. vue里在自定义的组件上定义的事件,都被认为是自定义事件,必须用$emit()来触发. 这也是子组件向父传值的原理. 如果想作为原生事件,需要在原生事件后面加上.nat ...
- Vue 2.0 右键菜单组件 Vue Context Menu
Vue 2.0 右键菜单组件 Vue Context Menu https://juejin.im/entry/5976d14751882507db6e839c
- vue3系列:vue3.0自定义全局弹层V3Layer|vue3.x pc桌面端弹窗组件
基于Vue3.0开发PC桌面端自定义对话框组件V3Layer. 前两天有分享一个vue3.0移动端弹出层组件,今天分享的是最新开发的vue3.0版pc端弹窗组件. V3Layer 一款使用vue3.0 ...
- Vuejs自定义全局组件--loading
不管是使用框架,还是不使用任何的框架,我们都不可避免的需要与“加载中……”打交道,刚刚学习了Vuejs自定义组件的写法,就现学现卖,介绍一下吧! 先看一下目录结构,一般情况下,每一个组件都新建一个新的 ...
- vue.js中的全局组件和局部组件
组件(Component)是 Vue.js 最强大的功能之一.组件可以扩展 HTML 元素,封装可重用的代码.在较高层面上,组件是自定义元素, Vue.js 的编译器为它添加特殊功能. 组件的使用有三 ...
- Vue.2.0.5-单文件组件
介绍 在很多Vue项目中,我们使用 Vue.component 来定义全局组件,紧接着用new Vue({ el: '#container '}) 在每个页面内指定一个容器元素. 这种方案在只是使用 ...
- vue 复习篇. 注册全局组件,和 组件库
初篇 ============================================================== 1. 编写loading组件(components/Loading/ ...
随机推荐
- vue列表数据倒计时存在的一些坑
vue 列表数据倒计时,在页面销毁前需要清除定时器,否着会报错. export default { data() { return { list: [] } }, mounted() { for (l ...
- HDU-2222 Keywords Search 字符串问题 AC自动机
题目链接:https://cn.vjudge.net/problem/HDU-2222 题意 给一些关键词,和一个待查询的字符串 问这个字符串里包含多少种关键词 思路 AC自动机模版题咯 注意一般情况 ...
- [洛谷P1835]素数密度
题目大意:求区间[l,r]中素数的个数($1\leq l,r\le 2^{31}$,$r-l\leq 10^6$). 解题思路:首先,用筛法筛出$2~\sqrt{r}$内的素数. 然后用这些素数筛l~ ...
- maven 安装jar包
1 下载maven: 下载路径: http://mirrors.hust.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-b ...
- 紫书 例题8-14 UVa 1607 (二分)
题意非常难理解-- #include<cstdio> #define REP(i, a, b) for(int i = (a); i < (b); i++) using namesp ...
- 2015 Multi-University Training Contest 3 hdu 5323 Solve this interesting problem
Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- hdu 1978 记忆化搜索
注意: dp[i][j] 表示(i,j)这个点有多少种方式 mark[i][j]表示这个点是否走过 假设有直接返回dp[i][j] dp的求法为全部梦走到点的dp的和 注意mark ...
- leetCode(38):Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...
- SGU 210 Acdream 1227 Beloved Sons KM
题目链接:点击打开链接 题意: 给定n个人 每一个人的点权 以下n行i行表示第i个人能够获得哪些数(数字从1-n.且不能反复分配) 若这个人获得了数字则你能够获得他的权值. 要你能获得的权值和最大. ...
- 走进windows编程的世界-----消息处理函数(2)
一 WM_PAINT消息 1 WM_PAINT的产生 因为窗体的互相覆盖等,产生须要绘制的区域,那么会产生WM_PAINT消息. 普通情况下,不直接发送WM_PAINT消息,通过API声明须要 ...