最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue?extend+promise封裝全局彈窗組件

 更新時(shí)間:2022年04月11日 13:50:59   作者:深圳最菜的前端  
這篇文章主要為大家詳細(xì)介紹了vue?extend+promise封裝全局彈窗組件,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue extend+promise封裝全局彈窗組件的具體代碼,供大家參考,具體內(nèi)容如下

因?yàn)轫?xiàng)目沒(méi)有引入第三方UI庫(kù),所以所有的公共組件都需要自己封裝
現(xiàn)在需要一個(gè)全局的彈窗,要有promise異步處理

實(shí)現(xiàn)后的效果

// components/confirm文件
<template>
? <div class="popup-wrap" v-if="showPopup">
? ? <div class="popup-center">
? ? ? <div class="popup-content">
? ? ? ? <div class="popup-close" @click="close"></div>
? ? ? ? <div class="title">{{ title }}</div>
? ? ? ? <div class="describe">{{ content }}</div>
? ? ? ? <div class="btn">
? ? ? ? ? <div :class="['btn-right', active == 'cancal' ? 'active' : '']" @click="handleClick('cancal')">{{cancelBtnText}}</div>
? ? ? ? ? <div :class="['btn-right', active == 'yes' ? 'active' : '']" @click="handleClick('yes')">{{yesBtnText}}</div>
? ? ? ? </div>
? ? ? </div>
? ? </div>
? </div>
</template>

<script>
export default {
? data() {
? ? return {
? ? ? showPopup: false,
? ? ? title: "", //標(biāo)題
? ? ? content: "", //提示文字
? ? ? yesBtnText: "", //確定按鈕
? ? ? cancelBtnText: "", //取消按鈕
? ? ? promiseStatus: null,
? ? ? active: "",
? ? };
? },
? watch: {},
? props: {},
? mounted () {
? ? this.confirm()
? },
? methods: {
? ? confirm() {
? ? ? this.showPopup = true;
? ? ? return new Promise((resolve, reject) => {
? ? ? ? this.promiseStatus = { resolve, reject };
? ? ? });
? ? },
? ? handleClick(e) {
? ? ? this.active = e;
? ? ? if (e == "yes") {
? ? ? ? this.promiseStatus && this.promiseStatus.resolve();
? ? ? } else {
? ? ? ? this.promiseStatus && this.promiseStatus.reject();
? ? ? }
? ? ? this.showPopup = false
? ? },
? ? close() {
? ? ? this.showPopup = false
? ? ? ?this.promiseStatus && this.promiseStatus.reject();
? ? ? // this.$emit("close");
? ? },
? },
};
</script>
<style lang="less" scoped>
.popup-wrap {
? width: 100%;
? height: 100%;
? background-color: rgba(0, 0, 0, 0.6);
? position: fixed;
? top: 0rem;
? left: 0rem;
? right: 0rem;
? bottom: 0rem;
? z-index: 9999;
? display: flex;
? align-items: center;
? justify-content: center;
? .popup-center {
? ? width: 990px;
? ? height: 413px;
? ? background-size: 990px 413px;
? ? display: flex;
? ? align-items: center;
? ? justify-content: center;
? ? .popup-content {
? ? ? position: absolute;
? ? ? width: 970px;
? ? ? height: 393px;
? ? ? background: linear-gradient(
? ? ? ? 180deg,
? ? ? ? rgba(5, 20, 39, 0.9) 0%,
? ? ? ? rgba(3, 17, 33, 0.9) 54%,
? ? ? ? rgba(1, 33, 74, 0.9) 100%
? ? ? );
? ? ? .popup-close {
? ? ? ? cursor: pointer;
? ? ? ? position: relative;
? ? ? ? top: 45px;
? ? ? ? left: 900px;
? ? ? ? width: 26px;
? ? ? ? height: 26px;
? ? ? ? border: 1px solid #fff;
? ? ? ? background-size: 100% 100%;
? ? ? }
? ? ? .title {
? ? ? ? text-align: center;
? ? ? ? margin-top: 50px;
? ? ? ? font-size: 40px;
? ? ? ? font-family: PingFangSC-Semibold, PingFang SC;
? ? ? ? font-weight: 600;
? ? ? ? color: #258df9;
? ? ? ? line-height: 56px;
? ? ? ? background: linear-gradient(180deg, #afebff 0%, #ffffff 100%);
? ? ? ? -webkit-background-clip: text;
? ? ? ? -webkit-text-fill-color: transparent;
? ? ? }
? ? ? .describe {
? ? ? ? text-align: center;
? ? ? ? margin-top: 30px;
? ? ? ? font-size: 28px;
? ? ? ? font-family: PingFangSC-Regular, PingFang SC;
? ? ? ? font-weight: 400;
? ? ? ? color: #a4bace;
? ? ? ? line-height: 40px;
? ? ? }
? ? }
? }
? .btn {
? ? width: 540px;
? ? height: 76px;
? ? margin: 0 auto;
? ? margin-top: 45px;
? ? display: flex;
? ? align-items: center;
? ? justify-content: space-between;
? ? .btn-right {
? ? ? cursor: pointer;
? ? ? width: 200px;
? ? ? height: 76px;
? ? ? border: 2px solid #a4bace;
? ? ? font-size: 30px;
? ? ? font-family: PingFangSC-Regular, PingFang SC;
? ? ? font-weight: 400;
? ? ? color: #a4bace;
? ? ? line-height: 76px;
? ? ? text-align: center;
? ? ? &.active {
? ? ? ? border: 2px solid #258df9;
? ? ? ? background: rgba(37, 141, 249, 0.3);
? ? ? ? color: #afebff;
? ? ? }
? ? }
? }
}
</style>
// js文件,這個(gè)文件看你們自己吧,寫在哪里都可以
// utils/confirm.js
import Confirm from '@/components/confirm.vue'
import Vue from "vue";
const ConfirmBox = Vue.extend(Confirm);
/* @使用方法 this.$confirm進(jìn)行調(diào)用
?* this.$confirm("此操作將永久刪除該文件, 是否繼續(xù)?", "確定執(zhí)行刪除操作嗎", {
? ? ? cancelBtnText: "取消",
? ? ? yesBtnText: "確認(rèn)執(zhí)行",
? ? })
? ? .then(() => {
? ? ? console.log("點(diǎn)擊了確認(rèn)按鈕");
? ? })
? ? .catch(() => {
? ? ? console.log("點(diǎn)擊了取消按鈕cancel");
? ? });
?*/
? Confirm.install = (content, title, options) => {
? ? if (typeof title === 'object') {
? ? ? options = title;
? ? ? title = '';
? ? } else if (title === undefined) {
? ? ? title = '';
? ? }
??
? ? options = Object.assign({
? ? ? title: title,
? ? ? content: content,
? ? }, options);
??
? ? let instance = new ConfirmBox({
? ? ? data: options
? ? }).$mount();
? ? document.body.appendChild(instance.$el);
? ? return instance.confirm();
? };
// mine.js 在根路徑進(jìn)行掛載
import "@/util/confirm" // 引入js
import Confirm from '@/components/confirm' ?//Confirm組件
Vue.config.productionTip = false //阻止啟動(dòng)生產(chǎn)消息,常用作指令 ?消息提示的環(huán)境配置,設(shè)置為開(kāi)發(fā)環(huán)境或者生產(chǎn)環(huán)境
Vue.prototype.$confirm = Confirm.install; //Confirm組
// 使用?
// home.vue
<template>
?? ?<div @click="handleClick">點(diǎn)擊</div>
</template>

<script>
export.default = {
?? ?data () {},
?? ?methdos: {
?? ??? ?handleClick () {
?? ??? ??? ?this.$confirm("此操作將永久刪除該文件, 是否繼續(xù)?", "確定執(zhí)行刪除操作嗎", {
?? ??? ? ? ? ? ?cancelBtnText: "取消",
?? ??? ? ? ? ? ?yesBtnText: "確認(rèn)執(zhí)行",
?? ??? ? ? ? ?})
?? ??? ? ? ? ?.then(() => {
?? ??? ? ? ? ? ?console.log("點(diǎn)擊了確認(rèn)按鈕");
?? ??? ? ? ? ?})
?? ??? ? ? ? ?.catch(() => {
?? ??? ? ? ? ? ?console.log("點(diǎn)擊了取消按鈕cancel");
?? ??? ? ? ? ?});
?? ??? ?}
?? ?}
}
</script>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue點(diǎn)擊自增和求和的實(shí)例代碼

    vue點(diǎn)擊自增和求和的實(shí)例代碼

    今天小編就為大家分享一篇vue點(diǎn)擊自增和求和的實(shí)例代碼,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-11-11
  • vue用elementui寫form表單時(shí),在label里添加空格操作

    vue用elementui寫form表單時(shí),在label里添加空格操作

    這篇文章主要介紹了vue用elementui寫form表單時(shí),在label里添加空格操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-08-08
  • 在項(xiàng)目vue中使用echarts的操作步驟

    在項(xiàng)目vue中使用echarts的操作步驟

    這篇文章主要介紹了在項(xiàng)目vue中使用echarts的操作步驟,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-09-09
  • vue將某個(gè)組件打包成js并在其他項(xiàng)目使用

    vue將某個(gè)組件打包成js并在其他項(xiàng)目使用

    這篇文章主要給大家介紹了關(guān)于vue將某個(gè)組件打包成js并在其他項(xiàng)目使用的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-07-07
  • Vue?element實(shí)現(xiàn)權(quán)限管理業(yè)務(wù)流程詳解

    Vue?element實(shí)現(xiàn)權(quán)限管理業(yè)務(wù)流程詳解

    目前本人再使用vue-element-admin項(xiàng)目時(shí)都是通過(guò)直接刪除一些用不上的路由來(lái)進(jìn)行側(cè)邊欄的清除,但是其實(shí)有一個(gè)更加好的辦法來(lái)對(duì)項(xiàng)目的側(cè)邊欄顯示的內(nèi)用進(jìn)行管理,就是權(quán)限管理,其實(shí)也不知道這個(gè)方法好不好,原理上來(lái)說(shuō)時(shí)跟直接刪除該路由的方式時(shí)一樣的
    2022-08-08
  • Vue mock.js模擬數(shù)據(jù)實(shí)現(xiàn)首頁(yè)導(dǎo)航與左側(cè)菜單功能

    Vue mock.js模擬數(shù)據(jù)實(shí)現(xiàn)首頁(yè)導(dǎo)航與左側(cè)菜單功能

    這篇文章主要介紹了Vue mock.js模擬數(shù)據(jù)實(shí)現(xiàn)首頁(yè)導(dǎo)航與左側(cè)菜單功能,mockjs是用來(lái)模擬產(chǎn)生一些虛擬的數(shù)據(jù),可以讓前端在后端接口還沒(méi)有開(kāi)發(fā)出來(lái)時(shí)獨(dú)立開(kāi)發(fā)。我們可以使用真實(shí)的url,mockjs可以攔截ajax請(qǐng)求,返回設(shè)定好的數(shù)據(jù)
    2022-09-09
  • vue-video-player 斷點(diǎn)續(xù)播的實(shí)現(xiàn)

    vue-video-player 斷點(diǎn)續(xù)播的實(shí)現(xiàn)

    這篇文章主要介紹了vue-video-player 斷點(diǎn)續(xù)播的實(shí)現(xiàn),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-02-02
  • iphone劉海屏頁(yè)面適配方法

    iphone劉海屏頁(yè)面適配方法

    這篇文章主要介紹了iphone劉海屏頁(yè)面適配方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • VueX?mapGetters獲取Modules中的Getters方式

    VueX?mapGetters獲取Modules中的Getters方式

    這篇文章主要介紹了VueX?mapGetters獲取Modules中的Getters方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • 關(guān)于VUE的編譯作用域及slot作用域插槽問(wèn)題

    關(guān)于VUE的編譯作用域及slot作用域插槽問(wèn)題

    這篇文章主要介紹了VUE 的編譯作用域及slot作用域插槽問(wèn)題,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-07-07

最新評(píng)論

平凉市| 宁城县| 青铜峡市| 治县。| 新郑市| 玉环县| 新河县| 石家庄市| 霍山县| 丽水市| 乌拉特后旗| 沁源县| 芒康县| 盈江县| 永昌县| 鲁甸县| 大邑县| 重庆市| 溆浦县| 长子县| 盈江县| 沁阳市| 富蕴县| 金川县| 大洼县| 弥渡县| 永州市| 阿荣旗| 璧山县| 和林格尔县| 长宁县| 台湾省| 临海市| 寿阳县| 同心县| 洮南市| 尉氏县| 正阳县| 库尔勒市| 无为县| 闽清县|