Skip to content

Notice 消息通知

消息通知组件,用于在页面上显示通知消息,支持配置消息类型、文本、持续时间等。

支持平台

安卓iosweb微信小程序支付宝小程序QQ小程序
xxx

示例

html
<template>
	<t-page title="消息提示列表">
		<t-card class="mltr.30" title='Notice 通知提示列表' sub-title="..."></t-card>
		<t-notify ref="notify"></t-notify>
		<introduction title="基础功能">
			<t-button type="primary" @click="addMessage">随机一条默认配置消息</t-button>
		</introduction>
		<introduction title="设置图标">
			<t-button type="primary" class="mb.30" @click="addMessage1('error-circle')">提示</t-button>
			<t-button type="error" @click="addMessage1('close-circle')">错误</t-button>
		</introduction>
	</t-page>
</template>

<script>
	import { random } from '@/uni_modules/t-ui'
	export default {
		data() {
			return {

			};
		},
		methods: {
			addMessage() {
				const notify : ComponentPublicInstance = this.$refs['notify'] as ComponentPublicInstance
				let not = ['欢迎使用Tui', '欢迎使用Tui', '晓云含雨却低徊', '大江东去浪淘尽']
				let typelist = ['primary', 'error', 'warning', 'success']
				notify.$callMethod('add', {
					type: typelist[random(0, 3)],
					text: not[random(0, 3)],
					duration: 1000
				})
			},
			addMessage1(icon : string) {
				const notify : ComponentPublicInstance = this.$refs['notify'] as ComponentPublicInstance
				let not = ['欢迎使用Tui', '欢迎使用Tui', '晓云含雨却低徊', '大江东去浪淘尽']
				let typelist = ['primary', 'error', 'warning', 'success']

				notify.$callMethod('add', {
					type: typelist[random(0, 3)],
					text: not[random(0, 3)],
					duration: 1000,
					icon
				})
			}
		}

	}
</script>

<style lang="scss">

</style>

Methods

方法名描述参数
add添加消息option : UTSJSONObject