alert.vue 1003 字节
Newer Older
lizhongyi_'s avatar
lizhongyi_ 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
<template>
	<view>
		<page-head :title="title"></page-head>
		<view class="uni-padding-wrap uni-common-mt">
			<button @tap="testShowAlert">确认框</button>
			<button @tap="testShowPrompt">输入框</button>
		</view>
	</view>

</template>

<script>
	import { showAlert,showPrompt } from '@/uni_modules/uts-alert'
	export default {
		
		data() {
			return {
				title:"Alert 示例"
			}
		},
		methods:{
			
			testShowAlert(){
				showAlert("提示框","这是一个提示框", (index)=> {
					
					var title = null
					if (index == 0) {
						title = "点击了确认"
					} else{
						title = "点击了取消"
					}
					
					uni.showToast({
						title: title,
						icon:'none'
					})
				})
			},
			testShowPrompt() {
				showPrompt("输入框","这是一个输入框","请输入内容", (content)=>{
					let title = content.length > 0 ? content : "没有输入内容"
					uni.showToast({
						title: title,
						icon:'none'
					})
				})
			}
		}
	}
</script>

<style>
</style>