var tpl1={
template:'#stpl1',
data:function(){
return {msg:false}
},
methods:{
msgf:function(){
this.msg=!this.msg
}
}
}
var tpl2={
template:'#stpl2',
data:function(){
return {msg:false}
},
methods:{
show:function(){
this.msg=true
},
hide:function(){
this.msg=false
}
}
}
new Vue({
el:'#box',
components:{
tpla:tpl1,
tplb:tpl2,
}
})
// 首先,定义一个混合对象
var mymixin = {
data:function(){
return {msg:false}
},
methods:{
show:function(){
this.msg=true
},
hide:function(){
this.msg=false
},
msgf:function(){
this.msg=!this.msg
}
}
}
var tpl1={
template:'#stpl1',
minins:[mymixin]
}
var tpl2={
template:'#stpl2',
minins:[mymixin]
}
// 如果我们需要在第一个组件定义data为true时,我们可以直接在组件内定义,他会覆盖mixin的data
var tpl1={
template:'#stpl1',
minins:[mymixin],
data:function(){
msg:true
}
}
// 注册一个全局自定义指令 v-focus
Vue.directive('focus', {
// 当绑定元素插入到 DOM 中。
inserted: function (el) {
// 聚焦元素
el.focus()
}
})
directives: {
focus: {
// 指令的定义---
}
}
<input v-focus>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有