/**
* modal 模态接口参数
* @param {string} modal.title 模态框标题
* @param {string} modal.text 模态框内容
* @param {boolean} modal.showbtn 是否显示按钮
* @param {string} modal.btnText 按钮文字
*/
Vue.component('tips', {
props : ['tipsOptions'],
template : '#tips',
data(){
return{
show : false
}
},
computed:{
tips : {
get() {
let tips = this.tipsOptions || {};
tips = {
title: tips.title || '提示',
text: tips.text || '',
showbtn : tips.showbtn || true,
btnText : tips.btnText || '确定'
};
// console.log(tips);
return tips;
}
}
}
})
<div class="tips" v-show="show" transition="fade">
<div class="tips-close" @click="closeTips">x</div>
<div class="tips-header">
<slot name="header">
<p class="title">{{tips.title}}</p>
</slot>
</div>
<div class="tips-body">
<slot name="body">
<p class="notice">{{tips.text}}</p>
</slot>
</div>
<div class="tips-footer">
<a href="javascript:;" rel="external nofollow" rel="external nofollow" v-if="tips.showbtn" @click="yes" >{{tips.btnText}}</a>
</div>
</div>
.tips {
position: fixed;
left: 10px;
bottom: 10px;
z-index: 1001;
-webkit-overflow-scrolling: touch;
max-width: 690px;
width: 260px;
padding: 10px;
background: #fff;
box-shadow: 0 0 10px #888;
border-radius: 4px;
}
.tips-close{
position: absolute;
top: 0;
right: 0;
width: 20px;
height: 20px;
line-height: 20px;
text-align: center;
}
.tips-header{
text-align: center;
font-size: 25px;
}
methods:{
closeTips(){
this.show = false;
},
yes : function(){
this.show = false;
this.$emit('yes', {name:'wenzi', age:36}); // 触发yes事件
},
showTips(){
var self = this;
self.show = true;
setTimeout(function(){
// self.show = false;
}, 2000)
}
}
<div class="app">
<a href="javascript:;" rel="external nofollow" rel="external nofollow" @click="showtips">显示</a>
<tips :tips-options="tipsOptions" ref="dialog" @yes="yes" v-cloak >
<h3 slot="header">提示标题</h3>
<div slot="body">
<p>hello world</p>
<p>wenzi</p>
</div>
</tips>
</div>
var app = new Vue({
el : '.app',
data : {
tipsOptions : {
title : 'tip'
}
}
methods:{
// 监听从组件内传递出来的事件
yes(args){
// console.log( args );
alert( JSON.stringify(args) );
},
// 显示tips
showtips(){
// console.log( this.$refs );
this.$refs.dialog.showTips();
}
}
})
props: ['initialCounter'],
data: function () {
return { counter: this.initialCounter }
}
props: ['size'],
computed: {
normalizedSize: function () {
return this.size.trim().toLowerCase()
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有