vue定义全局组件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link href="https://cdn.bootcss.com/twitter-bootstrap/4.1.3/css/bootstrap.css" rel="stylesheet">
</head>
<body>
<div id="app">
<my-com1></my-com1>
<my2></my2>
<mycon3></mycon3>
<counter></counter>
</div>
<script src="https://cdn.bootcss.com/vue/2.5.20/vue.min.js"></script>
<script src="https://cdn.bootcss.com/vue-resource/1.5.1/vue-resource.min.js"></script>
<script>
let com1 = Vue.extend({
template:'<h2>vue创建组件</h2>'
})
Vue.component('myCom1',com1);
Vue.component('my2',{
template:'<div><h1>myw</h1></div>'
})
Vue.component('mycon3',{
template:'<h1>{{msg}}</h1>',
data:function(){
return{
msg:'组件定义data数据'
}
}
})
//var dataObj = {count:0}//共享
Vue.component('counter',{
template:'<div><input type="button" value="+1" @click="inc"><h3>{{count}}</h3></div>',
data:function(){
return {count:0};
},
methods:{
inc(){
this.count++;
}
}
})
var vm = new Vue({
el:'#app',
data:{
},
methods:{
}
})
</script>
</body>
</html>
vue定义全局组件的更多相关文章
- vue(3)—— vue的全局组件、局部组件
组件 vue有局部组件和全局组件,这个组件后期用的会比较多,也是非常重要的 局部组件 template与components属性结合使用挂载 其中 Vmain.Vheader.Vleft.Vconte ...
- vue 定义全局函数,监听android返回键事件
vue 定义全局函数,监听android返回键事件 方法一:main.js 注入(1)在main.js中写入函数Vue.prototype.changeData = function (){ aler ...
- TZ_16_Vue定义全局组件和局部组件
1.定义全局组件 我们通过Vue的component方法来定义一个全局组件. <div id="app"> <!--使用定义好的全局组件--> <co ...
- vue定义全局方法 调用其他组件的方法
官网的写法 vue实例.$on就可以在根实例上定义全局方法 this.$root就是获取根实例 如果没有根实例 就表示当前实例 this.$root.$on 不需要.eventHub 不需要下面这 ...
- vue.2.0-自定义全局组件
App.vue <template> <div id="app"> <h3>welcome vue-loading</h3> < ...
- vue 的全局组件和 局部组件
vue组件局部与全局注册的区别 //局部注册 var mycomponent = new extend({ <!--Vue.extend()是Vue构造器的扩展,调用Vue.e ...
- vue定义全局date过滤器(自定义JS文件模块和Moment.js库)
自定义dateFormat.js文件模块 dateFormat.js /** * 时间字符串 转 时间戳 * @param {String} time_str 时间字符串(格式"2014-0 ...
- vue中全局组件与局部组件的注册,以及动态绑定props值
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Vue创建全局组件
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
随机推荐
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)
A. Find a Number 找到一个树,可以被d整除,且数字和为s 记忆化搜索 static class S{ int mod,s; String str; public S(int mod, ...
- .net 解压缩 rar文件
public static class RARHelper { public static bool ExistsWinRar() { bool result = false; string key ...
- box-shaw四边阴影详解
四边设置: /*设置四边不同颜色外阴影*/ .element{ box-shadow:-10px 0 10px red, /*左边阴影*/ 10px 0 10px yellow, /*右边阴影*/ 0 ...
- JavaScript之iframe页面间通信
[1] iframe父子页面间通信 1.相互调用对方的方法 |> 子级页面调用父级页面 window.parent.父级页面方法(args) |> 父级页面调用子级页面 document. ...
- 深入理解python装饰器
写在前面,参考文章链接: 1.博客园(https://www.cnblogs.com/everzin/p/8594707.html) 2.公众号文章 装饰器是什么,什么时候会用到装饰器呢? 写代码要遵 ...
- 使用ansible实现轻量级的批量主机管理
作者:邓聪聪 查看ansible配置文件下的hosts的文件 [root@ansible-server scripts]# cat /etc/ansible/hosts [test] 172.16.1 ...
- jquery.form插件 提交表单 type="hidden"取不到值的问题记录
1.外国文献:说可以改成其他的(非hidden),再加style="display:none"隐藏. <INPUT type="password" sty ...
- DGTween 控制物体移动并且播放相应的动画
假设有以上的状态,咱们不动的时候需要播放发呆的动画,然后任意时刻会进行Run的行动.于是有了以上的状态机. 为了完成目标追踪,比如跟随咱们的光标,这时候就需要将如以下代码: ani = gameObj ...
- Assets.car 解压工具 cartool 使用报错 segmentation fault cartool 解决方案
1 cartool 下载地址 https://github.com/steventroughtonsmith/cartool 由于在macOS Mojave系统上 之前代码会报错需要修改main.m ...
- Iterator 和 ListIterator 的不同点以及包含的方法
当我们在对集合(List,Set)进行操作的时候,为了实现对集合中的数据进行遍历,经常使用到了Iterator(迭代器).使用迭代器,你不需要干涉其遍历的过程,只需要每次取出一个你想要的数据进行处理就 ...