alert.vue 1.0 KB
Newer Older
lizhongyi_'s avatar
lizhongyi_ 已提交
1 2 3 4 5 6 7 8 9 10 11 12
<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>
13
  // #ifdef APP
lizhongyi_'s avatar
lizhongyi_ 已提交
14
	import { showAlert,showPrompt } from '@/uni_modules/uts-alert'
15
  // #endif
lizhongyi_'s avatar
lizhongyi_ 已提交
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 54 55
	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>