<template>
    <view>
        <view>
            
            <button @tap="test_showModal()">弹出测试</button>
            <button @tap="test_showActionSheet()">菜单选择</button>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                
            }
        },
        methods: {
            test_showModal(){
                uni.showModal({
                    title: '提示',
                    content: '这是一个模态弹窗',
                    success: function (res) {
                        if (res.confirm) {
                            console.log('用户点击确定');
                        } else if (res.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                });

            },
            test_showActionSheet(){
                uni.showActionSheet({
                    itemList: ['A', 'B', 'C'],
                    success: function (res) {
                        console.log(res);
                        console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
                    },
                    fail: function (res) {
                        console.log(res.errMsg);
                    }
                });

            },

            
        }
    }
</script>

<style>

</style>
 

<template>
	<view>
		<view>
			
			<button @tap="test_showModal()">弹出测试</button>
			<button @tap="test_showActionSheet()">菜单选择</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			test_showModal(){
				uni.showModal({
					title: '提示',
					content: '这是一个模态弹窗',
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});

			},
			test_showActionSheet(){
				uni.showActionSheet({
					itemList: ['A', 'B', 'C'],
					success: function (res) {
						console.log(res);
						console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
					},
					fail: function (res) {
						console.log(res.errMsg);
					}
				});

			},

			
		}
	}
</script>

<style>

</style>

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐