亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Vue實(shí)現(xiàn)簡(jiǎn)單彈窗效果

 更新時(shí)間:2022年09月20日 14:25:58   作者:y-zk  
這篇文章主要為大家詳細(xì)介紹了Vue實(shí)現(xiàn)簡(jiǎn)單彈窗效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Vue實(shí)現(xiàn)簡(jiǎn)單彈窗效果的具體代碼,供大家參考,具體內(nèi)容如下

選中input 彈出選項(xiàng)框

顯示彈窗

首先要在components中新建兩個(gè)組件 要實(shí)現(xiàn)子組件向父組件傳值

selest.vue 里面的內(nèi)容

<template>
? <div>
? ? <h1>選擇管理員</h1>
? ? <div class="sel" @click="show">{{ str }}</div>
? ? <template v-if="bol">
? ? ? <alt @ok="getData($event)" @cancel="close"></alt>
? ? </template>
? </div>
</template>

<script>
import Alt from "./alt.vue";
export default {
? name: "Select",
? data() {
? ? return {
? ? ? bol: false,
? ? ? str: '',
? ? };
? },
? components: {
? ? Alt,
? },
? methods: {
? ? show() {
? ? ? this.bol = true;
? ? },
? ? // 獲取數(shù)據(jù)方法
? ? getData(data) {
? ? ? // 關(guān)閉彈出層
? ? ? this.bol = false;
? ? ? console.log(data);
? ? ? this.str = data;
? ? },
? ? // 關(guān)閉彈窗
? ? close() {
? ? ? // 關(guān)閉彈出層
? ? ? this.bol = false;
? ? },
? },
};
</script>

<style scoped>
.sel {
? width: 200px;
? height: 40px;
? border: 1px solid #ccc;
? line-height: 40px;
? text-align: center;
? cursor: pointer;
? margin: 0 auto;
}
</style>

alt.vue 里面的內(nèi)容

<template>
? <div class="mark">
? ? <div class="alert">
? ? ? <!-- 內(nèi)容 -->
? ? ? <div class="cont">
? ? ? ? <div>
? ? ? ? ? <!-- 左邊的列表 -->
? ? ? ? ? <dl class="left">
? ? ? ? ? ? <dt>
? ? ? ? ? ? ? <label><input type="checkbox" v-model="allBol" :checke="allBol" @change="all" />全選</label>
? ? ? ? ? ? </dt>
? ? ? ? ? ? <dd v-for="(item,index) in arrL" :key="index">
? ? ? ? ? ? ? <label>
? ? ? ? ? ? ? ? <input type="checkbox" :checked="item.bol" v-model="item.bol" @change="only(index)" />
? ? ? ? ? ? ? ? <img :src="item.headurl" alt="">
? ? ? ? ? ? ? ? <span>{{item.name}}</span>
? ? ? ? ? ? ? </label>
? ? ? ? ? ? </dd>
? ? ? ? ? </dl>
? ? ? ? </div>
? ? ? ? <div>
? ? ? ? ?<dl class="left">
? ? ? ? ? ? <dd v-for="(item,index) in arrR" :key="index">
? ? ? ? ? ? ? <label>
? ? ? ? ? ? ? ? <img :src="item.headurl" alt="">
? ? ? ? ? ? ? ? <span>{{item.name}}</span>
? ? ? ? ? ? ? </label>
? ? ? ? ? ? ? <em @click="del(item,index)">×</em>
? ? ? ? ? ? </dd>
? ? ? ? ? </dl>
? ? ? ? </div>
? ? ? </div>
? ? ? <!-- 按鈕 -->
? ? ? <div class="btns">
? ? ? ? <button @click="sure">確定</button>
? ? ? ? <button @click="cancel">取消</button>
? ? ? </div>
? ? </div>
? </div>
</template>

<script>
export default {
? data() {
? ? return {
? ? ? allBol: false,
? ? ? arrL: [
? ? ? ? { name: '花木蘭', id: 1, headurl: require('../assets/logo.png'), bol: false },
? ? ? ? { name: '拓跋燾', id: 2, headurl: require('../assets/logo.png'), bol: false },
? ? ? ? { name: '宇文泰', id: 1, headurl: require('../assets/logo.png'), bol: false },
? ? ? ? { name: '宇文成都', id: 1, headurl: require('../assets/logo.png'), bol: false },
? ? ? ? { name: '宇文護(hù)', id: 1, headurl: require('../assets/logo.png'), bol: false },
? ? ? ? { name: '宇文拓', id: 1, headurl: require('../assets/logo.png'), bol: false }
? ? ? ],
? ? ? arrR: []
? ? }
? },
? methods: {
? ? // 點(diǎn)擊全選
? ? all() {
? ? ? // 清空一個(gè)數(shù)組
? ? ? this.arrR = []; // 第一種
? ? ? // this.arrR.length = 0; // 第二種
? ? ? this.arrL.map(item => {
? ? ? ? item.bol = this.allBol;
? ? ? ? if(this.allBol) {
? ? ? ? ? this.arrR.push(item);
? ? ? ? }
? ? ? })
? ? },
? ? // 點(diǎn)擊單選
? ? only(n) {
? ? ?if (this.arrL[n].bol) {
? ? ? ?this.arrR.push(this.arrL[n])
? ? ?}else {
? ? ? ?let index = this.arrR.indexOf(this.arrL[n]);
? ? ? ?this.arrR.splice(index,1);
? ? ? ?this.allBol = false
? ? ?}
? ? },
? ? // 刪除
? ? del(obj, index) {
? ? ? let n = this.arrL.indexOf(obj);
? ? ? this.arrL[n].bol = false;
? ? ? this.arrR.splice(index, 1)
? ? },
? ? // 點(diǎn)擊確定
? ? sure() {
? ? ? let arr = [];
? ? ? this.arrR.map(item => {
? ? ? ? arr.push(item.name)
? ? ? })
? ? ? this.$emit('ok', arr.join(','));
? ? },
? ? // 點(diǎn)擊取消
? ? cancel() {
? ? ? this.$emit('cancel')
? ? },
? }
};
</script>

<style scoped>
.mark {
? width: 100%;
? height: 100%;
? background: rgba(0, 0, 0, 0.5);
? position: fixed;
? left: 0;
? top: 0;
? z-index: 1000;
? display: flex;
? align-items: center;
? justify-content: center;
}

.alert{
? background: #fff;
? width: 800px;
? height: 600px;
}
.cont {
? display: flex;
? height: 500px;
}
.cont>div {
? flex: 1;
}
.cont>div:nth-child(1) {
? border-right: 1px #ccc solid;
}
.btns {
? height: 100px;
? text-align: center;
}
.left dd {
? height: 50px;
? margin-bottom: 10px;
? position: relative;
}
.left dd label {
? display: flex;
? height: 50px;
? align-items: center;
? cursor: pointer;
}
.left dd label:hover {
? background: #f0f0f0;
}
.left dd label img {
? width: 50px;
? height: 50px;
? border-radius: 50%;
? margin: 0 5px;
}
.left dd em {
? cursor: pointer;
? position: absolute;
? width: 50px;
? height: 50px;
? font-size: 30px;
? text-align: center;
? line-height: 50px;
? right: 0;
? top: 0;
? transition: all 0.8s;
}
.left dd em:hover{
? transform: rotate(360deg);
}

</style>

在App.vue 里面寫

<template>
? <div id="app">
? ? <div id="nav">
? ? ? <router-link to="/select">選擇管理員</router-link>
? ? </div>
? ? <router-view/>
? </div>
</template>

在router 下面的index.js 里面添加路由

import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
? {
? ? path: '/',
? ? name: 'Home',
? ? component: Home
? },
? {
? ? path: '/about',
? ? name: 'About',
? ? component: function () {
? ? ? return import('../views/About.vue')
? ? }
? },
? // 創(chuàng)建的路由
? {
? ? path: '/select',
? ? name: 'Select',
? ? component: () => import('../components/selest.vue')
? }
]

const router = new VueRouter({
? mode: 'history',
? base: process.env.BASE_URL,
? routes
})

export default router

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

相關(guān)文章

  • 將Vue組件庫(kù)更換為按需加載的方法步驟

    將Vue組件庫(kù)更換為按需加載的方法步驟

    這篇文章主要介紹了將Vue組件庫(kù)更換為按需加載的方法步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-05-05
  • 詳解vue+webpack+express中間件接口使用

    詳解vue+webpack+express中間件接口使用

    這篇文章主要介紹了詳解vue+webpack+express中間件接口使用,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-07-07
  • el-tree樹(shù)狀控件如何定位到選中的節(jié)點(diǎn)的位置

    el-tree樹(shù)狀控件如何定位到選中的節(jié)點(diǎn)的位置

    這篇文章主要介紹了el-tree樹(shù)狀控件如何定位到選中的節(jié)點(diǎn)的位置,本文通過(guò)示例代碼給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧
    2024-08-08
  • Vue生命周期詳解

    Vue生命周期詳解

    這篇文章詳細(xì)介紹了Vue的生命周期,文中通過(guò)代碼示例介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-04-04
  • 詳解vue axios用post提交的數(shù)據(jù)格式

    詳解vue axios用post提交的數(shù)據(jù)格式

    這篇文章主要介紹了詳解vue axios用post提交的數(shù)據(jù)格式,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-08-08
  • vue a標(biāo)簽點(diǎn)擊實(shí)現(xiàn)賦值方式

    vue a標(biāo)簽點(diǎn)擊實(shí)現(xiàn)賦值方式

    這篇文章主要介紹了vue a標(biāo)簽點(diǎn)擊實(shí)現(xiàn)賦值方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-09-09
  • Vue實(shí)現(xiàn)遞歸組件的思路與示例代碼

    Vue實(shí)現(xiàn)遞歸組件的思路與示例代碼

    以簡(jiǎn)單的樹(shù)形組件為案例,實(shí)現(xiàn)在組件中遞歸組件,下面這篇文章主要給大家介紹了關(guān)于Vue實(shí)現(xiàn)遞歸組件的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-09-09
  • vue添加axios,并且指定baseurl的方法

    vue添加axios,并且指定baseurl的方法

    今天小編就為大家分享一篇vue添加axios,并且指定baseurl的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-09-09
  • 解決VUE 在IE下出現(xiàn)ReferenceError: Promise未定義的問(wèn)題

    解決VUE 在IE下出現(xiàn)ReferenceError: Promise未定義的問(wèn)題

    這篇文章主要介紹了解決VUE 在IE下出現(xiàn)ReferenceError: Promise未定義的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-11-11
  • 基于elementUI實(shí)現(xiàn)圖片預(yù)覽組件的示例代碼

    基于elementUI實(shí)現(xiàn)圖片預(yù)覽組件的示例代碼

    這篇文章主要介紹了基于elementUI實(shí)現(xiàn)圖片預(yù)覽組件的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-03-03

最新評(píng)論