Vue自定義詢問彈框和輸入彈框的示例代碼
前端Vue自定義詢問彈框和輸入彈框, 下載完整代碼請訪問uni-app插件市場地址:https://ext.dcloud.net.cn/plugin?id=13119
效果圖如下:
使用方法
<!-- 提示框 --> <cc-defineDialogBox ref="DialogBox"></cc-defineDialogBox> // 顯示詢問彈框 showDialogBox() { this.$refs['DialogBox'].confirm({ title: '請確認您填寫的信息', content: '前端Vue開發(fā)?', DialogType: 'inquiry', animation: 0 }).then((res)=>{ console.log('res = ', JSON.stringify(res)); }) }, // 顯示輸入彈框 showDialogBoxInput() { this.$refs['DialogBox'].confirm({ title: '更改昵稱', placeholder: '請輸入修改的昵稱', value: this.nickname, DialogType: 'input', animation: 0 }).then((res)=>{ // 輸入框返回值res this.nickname = res.value; }) },
HTML代碼實現(xiàn)部分
<template> <view class="content"> <!-- 提示框 --> <cc-defineDialogBox ref="DialogBox"></cc-defineDialogBox> <!-- 顯示詢問彈框 --> <button @click="showDialogBox" style="width: 160px; height: 50px;background-color: antiquewhite; margin-top: 26px;">顯示詢問彈框</button> <!-- 顯示輸入彈框 --> <button @click="showDialogBoxInput" style="width: 160px; height: 50px;background-color: antiquewhite; margin-top: 26px;">顯示輸入彈框</button> </view> </template> <script> export default { data() { return { nickname: 'Hello' } }, onLoad() { }, methods: { // 顯示詢問彈框 showDialogBox() { this.$refs['DialogBox'].confirm({ title: '請確認您填寫的手機號', content: '手機號碼:13999999999?', DialogType: 'inquiry', animation: 0 }).then((res) => { console.log('res = ', JSON.stringify(res)); }) }, // 顯示輸入彈框 showDialogBoxInput() { this.$refs['DialogBox'].confirm({ title: '更改昵稱', placeholder: '請輸入修改的昵稱', value: this.nickname, DialogType: 'input', animation: 0 }).then((res) => { // 輸入框返回值res this.nickname = res.value; }) }, } } </script> <style> .content { display: flex; flex-direction: column; } </style>
到此這篇關(guān)于Vue自定義詢問彈框和輸入彈框 的文章就介紹到這了,更多相關(guān)vue自定義彈框內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Vue3.0使用ref和reactive來創(chuàng)建響應(yīng)式數(shù)據(jù)
ref?和?reactive?是?Composition?API?中用來創(chuàng)建響應(yīng)式數(shù)據(jù)的兩個核心函數(shù),在本篇文章中,我們將詳細講解如何使用?ref?和?reactive?來創(chuàng)建響應(yīng)式數(shù)據(jù),并展示它們之間的區(qū)別和使用場景,需要的朋友可以參考下2024-11-11解決webpack+Vue引入iView找不到字體文件的問題
今天小編就為大家分享一篇解決webpack+Vue引入iView找不到字體文件的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-09-09vue3+element?plus中利用el-menu如何實現(xiàn)路由跳轉(zhuǎn)
這篇文章主要給大家介紹了關(guān)于vue3+element?plus中利用el-menu如何實現(xiàn)路由跳轉(zhuǎn)的相關(guān)資料,在Vue?Router中我們可以使用el-menu組件來實現(xiàn)菜單導(dǎo)航,通過點擊菜單項來跳轉(zhuǎn)到不同的路由頁面,需要的朋友可以參考下2023-12-12vue實現(xiàn)動態(tài)路由添加功能的簡單方法(無廢話版本)
ue動態(tài)路由(約定路由),聽起來好像很玄乎的樣子,但是你要是理解了實現(xiàn)思路,你會發(fā)現(xiàn)沒有想象中的那么難,下面這篇文章主要給大家介紹了關(guān)于vue實現(xiàn)動態(tài)路由添加功能的簡單方法,需要的朋友可以參考下2023-02-02