热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

vue项目自定义提示框

{{tipsContent}}export default {props: {visible: Boolean,tipsContent: String},methods: {get() {if (th


<template><div :visible&#61;"visible" ref&#61;"tipsBox" &#64;update:visible&#61;"updateDialog" class&#61;"tipsBox"><div ref&#61;"showPopover" class&#61;"tipsClass animated"><div>{{tipsContent}}div>div>div>
template>
<script>
export default {props: {visible: Boolean,tipsContent: String},methods: {get() {if (this.visible) {this.$refs.tipsBox.children[0].className &#61; "tipsClass";this.updateDialog(false);} else {this.$refs.tipsBox.children[0].className &#61; "tipsClass animated";}},updateDialog(val) {this.$emit("update:visible", val);}},mounted() {this.timer &#61; setInterval(this.get, 1000);},beforeDestroy() {clearInterval(this.timer);}
};
script>
<style lang&#61;"scss" scoped>
.tipsClass {top: 60%;left: 50%;height: 30px;line-height: 30px;position: absolute;padding: 0 15px;background: black;font-size: 12px;margin: 0px auto;text-align: center;color: white;opacity: 1;transform: translate(-50%, -50%);border-radius: 3px;
}
.animated {opacity: 0;padding: 0;filter: Alpha(opacity&#61;0);transition: all 2s;
}
style>


<template><div class&#61;"short-message-signature"><el-button type&#61;"primary" &#64;click&#61;"submit">提交el-button><BombTips v-bind.sync&#61;"showBombTips" :tipsContent&#61;"tipsContent">BombTips>div>
template>
<script>
import BombTips from "&#64;/components/common/BombTips.vue";
export default {components: { BombTips },data() {return {showBombTips: {visible: false},tipsContent: ""};},methods: {submit() {this.showBombTips &#61; {visible: true};this.tipsContent &#61; "测试弹框的内容";},}
};
script>

效果如下&#xff1a;主要的代码都在上面了&#xff0c;效果图是从项目中截取出来的&#xff0c;效果是相同的


推荐阅读
author-avatar
mobiledu2502897157
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有