uni-app x列表弹窗 uts

336 阅读1分钟

插件地址弹窗 - DCloud 插件市场

注意:必须打包为自定义基座下载依赖(项目依赖 maven { url 'jitpack.io' })

<template>
    <view class="content">
        <button @click="newConfirm">显示确认和取消对话框</button>
        <button @click="newCenterList">显示中间弹出的列表弹窗</button>
        <button @click="newBottomList">显示从底部弹出的列表弹窗</button>
        <button @click="newCityPicker">城市选择器</button>
    </view>
</template>

<script>
    import { Confirm,CenterList,BottomList,CityPicker} from '@/uni_modules/wb-XPopup'
    export default {
        data() {
            return {
                title: 'Hello'
            }
        },
        onLoad() {

        },
        methods: {
            newConfirm() {
                let app =new Confirm()
                app.setTitleAndContent("提示","内容")
                app.setConfirmButtonText("确认",()=>{
                    console.log("确认触发");
                })
                app.setCancelButtonText("取消",false,()=>{
                    console.log("取消触发")
                })
                app.showConfirm()

            } ,
            newCenterList(){
                let app = new CenterList()
                let list =["item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1"] as string[]
                app.setTitleAndContent("提示",list)
                app.getOnSelectListener((index:Int,text:string)=>{
                    console.log(index,text);
                })
                app.showCenterList()
            },
            newBottomList(){
                let app = new BottomList()
                let list =["item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1","item1"] as string[]
                app.setTitleAndContent("提示",list)
                app.getOnSelectListener((index:Int,text:string)=>{
                    console.log(index,text);
                })
                app.showCenterList()
            },
            newCityPicker(){
                let app = new CityPicker()
                app.getCancel(()=>{
                    console.log("取消");
                })
                app.getChange((province:string,city:string,area:string)=>{
                    console.log("滚动");
                    console.log(province,city,area); 
                })
                app.getCityConfirm((province:string,city:string,area:string)=>{
                    console.log("确认");
                    console.log(province,city,area);
                })
                app.showCityPicker()
            }
        }
    }
</script>

弹窗 - DCloud 插件市场