uview中的常用的框

 第一步:

    先下载 uview UI 框架

    详见      项目 引入 uView_vue引入uview_qq_2524963996的博客-CSDN博客【代码】 项目 引入 uView。_vue引入uviewhttps://blog.csdn.net/qq_44161703/article/details/131168976?spm=1001.2014.3001.5501

  第二步:

   可以直接粘贴使用(只不过要修改一下样式根据自己的需要) 

   有 (输入框,Picker 选择器,Radio 单选框,Checkbox 复选框,Textarea 文本域,Overlay 遮罩层 ,Popup 弹出层,Switch  开关选择器,Tabs 标签, DatetimePicker 选择器,加载中..., Button 按钮,自定义导航栏,底部导航栏
插件 (查看PDF的,和  自滚动组件 )
//  自滚动组件    npm i vue-seamless-scroll -save 
    查看PDF的  插件市场  ---  
移动端-H5-小程序在线预览pdf,图片,视频 - DCloud 插件市场
    引入包 在你的项目中 路径已经写啦!
    里面有详细的说明

<template>
	<view class="">
		<!-- 导航栏  必须写在前面 height="100" placeholder suffixIcon(uview 图标库)  suffixIconStyle (icon颜色)-->
		<view class="navbar-icon">
			<u-navbar leftText="返回" @leftClick="leftClicks" title="202房间配餐" placeholder>
				<view class="u-nav-slot" slot="right">
					<view @click="pickerShowInput = true">
						<u--input suffixIcon="list-dot" suffixIconStyle="color: #02A7F0" disabled class="navbar-active" placeholder="请选择内容" v-model="navbarValue"></u--input>
						<u-picker @cancel="pickerShowInput = false" @confirm="navbarPickerValue" :show="pickerShowInput" :columns="navbarColumns"></u-picker>
					</view>
				</view>
			</u-navbar>
		</view>
		<!-- 导航栏end -->
		<!-- 滚动组件的使用 warnings 必须和循环的数据保持一样  classOption 计算属性中的东西 可以给自定义样式-->
		<vue-seamless-scroll :data="warnings" :class-option="classOption">
			<view class="" v-for="(item, index) in warnings" :key="item.id">
				{{ item.name }}
			</view>
		</vue-seamless-scroll>
		<!-- 滚动组件的使用end -->
		<!-- 输入框 -->
		<u--input maxlength="50" placeholder="请输入内容" v-model="inputValue"></u--input>
		<!-- 输入框 end -->
		<!-- Picker 选择器 -->
		<view @click="show = true">
			<u--input disabled class="active" placeholder="请选择内容" v-model="showValue"></u--input>
			<u-picker @cancel="show = false" @confirm="confirmValue" :show="show" :columns="columns"></u-picker>
		</view>
		<!-- Picker 选择器end-->
		<!-- Radio 单选框  -->
		<u-radio-group v-model="radiovalue1" placement="column" @change="groupChange">
			<u-radio :customStyle="{ marginBottom: '8px' }" v-for="(item, index) in radiolist1" :key="index" :label="item.name" :name="item.name"></u-radio>
		</u-radio-group>
		<!-- Radio 单选框end  -->
		<!-- Checkbox 复选框 -->
		<view>
			<u-checkbox-group iconPlacement="left" v-model="checkboxValue1" placement="column" @change="checkboxChange">
				<u-checkbox :customStyle="{ marginBottom: '8px' }" v-for="(item, index) in checkboxList1" :key="index" :label="item.name" :name="item.name"></u-checkbox>
			</u-checkbox-group>
		</view>
		<!-- Checkbox 复选框end -->
		<!-- Textarea 文本域  height autoHeight maxlength  -->
		<u--textarea height="100" autoHeight maxlength="1000" count v-model="value1" placeholder="请输入内容"></u--textarea>
		<!-- Textarea 文本域  height autoHeight maxlength end  -->
		<!-- Overlay 遮罩层  @click="show = false"-->
		<u-overlay :show="overlayShow">
			<view class="warp">
				<view class="rect" @tap.stop="overlayShow = false">关闭</view>
			</view>
		</u-overlay>
		<view class="" @click="overlayShow = true">打开遮罩</view>
		<!-- Overlay 遮罩层end -->

		<!-- Popup 弹出层  round   mode="top"-->
		<view>
			<u-popup safeAreaInsetBottom closeable :round="10" :show="popupShow" @close="close" @open="open">
				<view class="heght">
					<text>出淤泥而不染,濯清涟而不妖</text>
				</view>
			</u-popup>
			<u-button @click="popupShow = true">打开</u-button>
		</view>
		<!-- Popup 弹出层 end-->
		<!-- Switch  开关选择器  asyncChange-->
		<view class="">
			<u-switch asyncChange v-model="switchCalue" @change="change"></u-switch>
		</view>
		<!-- Switch 开关选择器end -->
		<!-- Button 按钮  :plain="true"(细边) disabled   icon="map" loading loadingText="加载中"-->
		<view class="">
			<u-button :plain="true" icon="map" shape="circle" type="primary" text="确定"></u-button>
			<u-button text="渐变色按钮" color="linear-gradient(to right, rgb(66, 83, 216), rgb(213, 51, 186))"></u-button>
			<!--  -->
		</view>
		<!-- Button 按钮 end -->
		<!-- Tabs 标签 -->
		<view class="">
			<u-tabs
				:list="list4"
				lineWidth="30"
				lineColor="#f56c6c"
				:activeStyle="{
					color: '#303133',
					fontWeight: 'bold',
					transform: 'scale(1.05)'
				}"
				:inactiveStyle="{
					color: '#606266',
					transform: 'scale(1)'
				}"
				itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;"
			></u-tabs>
		</view>
		<!-- Tabs 标签end -->
		<!-- DatetimePicker 选择器  		mode="date"-->
		<view class="">
			<view class="col-6" @click="pickerShowTime = true">
				<u--input class="active" disabled placeholder="请选择日期" :value="formatDate(tasktime)" suffixIcon="calendar" suffixIconStyle="color: #909399"></u--input>
				<u-datetime-picker
					:min-date="Number(new Date('2021-01-01'))"
					:max-date="Number(new Date('2035-01-01'))"
					:show="pickerShowTime"
					:formatter="formatter"
					v-model="tasktime"
					@cancel="cancel"
					mode="datetime"
					@confirm="confirm"
				></u-datetime-picker>
			</view>
		</view>
		<!-- DatetimePicker 选择器end -->

		<!-- 加载中...  vertical可以指定文字和图标是否垂直排列-->
		<view class="">
			<u-overlay :show="loadingShow">
				<view class="warp">
					<view class="rect1">
						<u-loading-icon vertical color="white" textColor="white" text="加载中..." textSize="14"></u-loading-icon>
					</view>
				</view>
			</u-overlay>
			<view class="" @click="loadingShow = true">打开遮罩加载中...</view>
		</view>
		<!--  加载中... end-->

		<view class=""></view>
		<!-- 底部导航栏  activeColor="#d81e06"(激活的颜色)inactive-icon(平常的样式)active-icon(激活的样式) fixed(固定底部) placeholder(生成一个等高元素防止塌陷)  safeAreaInsetBottom(	是否为iPhoneX留出底部安全距离)-->
		<u-tabbar activeColor="#d81e06" :border="false" :value="tabbarValue1" @change="tabbarChange1" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true">
			<u-tabbar-item text="首页">
				<image class="u-page__item__slot-icon" slot="active-icon" src="https://cdn.uviewui.com/uview/common/bell-selected.png"></image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="https://cdn.uviewui.com/uview/common/bell.png"></image>
			</u-tabbar-item>
			<u-tabbar-item text="放映厅" @click="tabbarItemclick1" icon="photo"></u-tabbar-item>
			<u-tabbar-item text="直播" @click="tabbarItemclick1" icon="play-right"></u-tabbar-item>
			<u-tabbar-item text="我的" @click="tabbarItemclick1" icon="account"></u-tabbar-item>
		</u-tabbar>

		<!-- 底部导航栏end -->
		<!-- 预览PDF fileType 1.预览图片,2.预览文件,3.预览视频  fileUrl 预览单个文档或视频传递url -->
		<!-- <ss-preview :fileType="fileType" :fileUrl="fileUrl"></ss-preview> -->
		<!-- 预览PDF  可以直接在插件市场引入看效果 -->
	</view>
</template>
<script>
// 滚动组件  npm i vue-seamless-scroll -save
import vueSeamlessScroll from 'vue-seamless-scroll';
// 滚动组件
// 预览 PDF 需要在官网引入 https://ext.dcloud.net.cn/plugin?id=11924 直接把包引入到你的项目中
// import ssPreview from '@/uni_modules/ss-preview/components/ss-preview/ss-preview.vue';
// 预览PDF end
export default {
	//注册滚动组件
	components: {
		vueSeamlessScroll
		// ssPreview
	},
	// 计算属性
	computed: {
		// 计算属性方法配置方式
		classOption() {
			return {
				step: 0.4, // 数值越大速度滚动越快
				limitMoveNum: this.warnings.length, // 开始无缝滚动的数据量 this.dataList.length
				hoverStop: true, // 是否开启鼠标悬停stop
				direction: 1, // 0向下 1向上 2向左 3向右
				openWatch: true, // 开启数据实时监控刷新dom
				singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1
				singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
				waitTime: 1000 // 单步运动停止的时间(默认值1000ms)
			};
		}
	},

	data() {
		return {
			// 自动滚动数据 一个数组(或者数组包含对象)
			warnings: [
				{
					id: 1,
					name: '李四1'
				},
				{
					id: 2,
					name: '李四2'
				},
				{
					id: 3,
					name: '李四3'
				},
				{
					id: 6,
					name: '李四4'
				},
				{
					id: 4,
					name: '李四5'
				},
				{
					id: 5,
					name: '李四6'
				}
			],
			// 输入框
			inputValue: '',
			// Textarea 文本域
			value1: '',
			// Picker 选择器
			show: false,
			columns: [['中国', '美国', '日本']],
			showValue: '',
			showValueIndex: '',
			// Picker 选择器 end
			// Radio 单选框
			radiolist1: [
				{
					name: '苹果',
					disabled: false
				},
				{
					name: '香蕉',
					disabled: false
				},
				{
					name: '橙子',
					disabled: false
				},
				{
					name: '榴莲',
					disabled: false
				}
			],
			// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
			radiovalue1: '苹果',
			// Radio 单选框 end
			// Checkbox 复选框
			checkboxValue1: ['苹果', '香蕉'],
			// 基本案列数据
			checkboxList1: [
				{
					name: '苹果',
					disabled: false
				},
				{
					name: '香蕉',
					disabled: false
				},
				{
					name: '橙子',
					disabled: false
				}
			],
			// Checkbox 复选框end
			// Overlay 遮罩层
			overlayShow: false,
			// Overlay 遮罩层end
			// Popup 弹出层
			popupShow: false,
			// Popup 弹出层end
			// Switch 开关选择器
			switchCalue: false,
			// Switch 开关选择器end
			// Tabs 标签
			list4: [
				{
					name: '关注'
				},
				{
					name: '推荐',
					badge: {
						isDot: true
					}
				},
				{
					name: '电影'
				},
				{
					name: '科技'
				},
				{
					name: '音乐'
				},
				{
					name: '美食'
				},
				{
					name: '文化'
				},
				{
					name: '财经'
				},
				{
					name: '手工'
				}
			],
			// Tabs 标签 end
			//  DatetimePicker 选择器
			pickerShowTime: false,
			tasktime: Number(new Date()),
			//  DatetimePicker 选择器end
			// 加载中...
			loadingShow: false,
			// 加载中...end

			// pickerShowInput  导航栏
			pickerShowInput: false,
			navbarColumns: [['导航', '导航1', '导航2']],
			navbarValue: '',
			// pickerShowInput  导航栏 end
			// 底部导航栏
			tabbarValue1: 3 //(匹配标签的名称 0---3 默认的 可以传组件使用)
			// 底部导航栏end
		};
	},

	methods: {
		// Picker 选择器
		confirmValue(e) {
			// 需要传给后端 根据需要
			this.showValueIndex = e.indexs[0] + 1;
			this.showValue = e.value[0];
			this.show = false;
		},
		// Picker 选择器 end
		// Radio 单选框
		groupChange(e) {
			console.log(e);
		},
		// Radio 单选框end
		// Checkbox 复选框
		checkboxChange(n) {
			console.log('change', n);
		},
		// Checkbox 复选框end
		// Popup 弹出层
		open() {
			// console.log('open');
			this.popupShow = true;
		},
		close() {
			this.popupShow = false;
			// console.log('close');
		},
		// Popup 弹出层 end
		// 异步控制弹窗 Switch 开关选择器
		change(e) {
			uni.showModal({
				content: e ? '确定要打开吗' : '确定要关闭吗',
				success: (res) => {
					if (res.confirm) {
						this.switchCalue = e;
					}
				}
			});
		},
		// 异步控制弹窗 Switch 开关选择器end
		//  DatetimePicker 选择器
		// 确定
		confirm(e) {
			this.tasktime = e.value;
			this.pickerShowTime = false;
		},
		// 取消
		cancel() {
			this.pickerShowTime = false;
		},
		formatDate(data) {
			let date = new Date(data);
			let year = date.getFullYear();
			let month = date.getMonth() + 1;
			let day = date.getDate();
			let hours = date.getHours();
			let minutes = date.getMinutes();
			let seconds = date.getSeconds();

			month = month > 9 ? month : '0' + month;
			day = day < 10 ? '0' + day : day;
			hours = hours > 9 ? hours : '0' + hours;
			minutes = minutes > 9 ? minutes : '0' + minutes;
			seconds = seconds > 9 ? seconds : '0' + seconds;
			// 格式调整
			return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
		},
		formatter(type, value) {
			const typeMap = {
				year: '年',
				month: '月',
				day: '日',
				hour: '时',
				minute: '分',
				second: '秒'
			};

			return typeMap[type] ? `${value}${typeMap[type]}` : value;
		},
		//  DatetimePicker 选择器end

		// 导航栏
		leftClicks() {
			// 返回上一层
			uni.navigateBack();
		},
		navbarPickerValue(e) {
			console.log('eenav', e);
			console.log('eenav', e.value[0]);
			this.navbarValue = e.value[0];
			this.pickerShowInput = false;
		},
		// 导航栏end
		// 底部导航栏
		tabbarChange1(name) {
			console.log('底部导航栏index', name);
			// 给激活的索引 ---name
			this.tabbarValue1 = name;
		},
		tabbarItemclick1(name) {
			console.log('底部导航栏item--index', name);
		}
		// 底部导航栏end
	}
};
</script>

<style scoped lang="less">
// Picker 选择器
.active {
	background-color: #fff !important;
}
// Picker 选择器 end
// Overlay 遮罩层
.warp {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
}

.rect {
	width: 120px;
	height: 120px;
	background-color: #fff;
}
// Overlay 遮罩层end

// Popup 弹出层
.heght {
	height: 80vh;
}
// Popup 弹出层end

// 导航栏
.u-nav-slot {
	width: 65%;
}
.navbar-active {
	background-color: #fff !important;
	height: 44rpx !important;
}
/deep/ .u-navbar__content__right {
	right: -170rpx !important;
	margin-left: 20rpx !important;
}
/deep/ .u-navbar__content__title {
	// position: absolute !important;
	// left: 216rpx !important;
	text-align: left !important;
	width: 220rpx !important;
}
// 导航栏 end

// 底部导航栏
/deep/ uni-image {
	width: 36rpx !important;
	height: 36rpx !important;
}
// 底部导航栏end
</style>

注意一点:
    写导航栏的时候 记得要自定义的 !!!  -------pagesjson

"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
		{
			"path": "pages/index/index",
			"style": {
				"navigationStyle": "custom", // 隐藏系统导航栏
				"navigationBarTextStyle": "white" // 状态栏字体为白色,只能为 white-白色,black-黑色 二选一
			}
		}
	],

以上就是 常用的框啦!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,uview的消息提示可以使用u-toast、u-message、u-modal等组件来实现。下面介绍一下这几种组件的使用方法: 1. u-toast组件 u-toast组件是一种轻量级的消息提示组件,可以用来显示简短的提示信息。 使用方法: 在需要使用u-toast组件的页面引入组件,并在页面注册使用u-toast组件。 ```vue <template> <view> <u-toast ref="toast" /> </view> </template> <script> import { uToast } from 'uview-ui'; export default { components: { uToast } } </script> ``` 在需要触发u-toast消息提示的事件,调用u-toast组件的show方法来显示提示信息。 ```javascript this.$refs.toast.show({ title: '提示', content: '这是一条提示消息', duration: 2000 }); ``` 其,title表示提示信息的标题,content表示提示信息的内容,duration表示提示信息的显示时间,单位为毫秒。 2. u-message组件 u-message组件是一种常用的消息提示组件,可以用来显示比较复杂的提示信息,包括成功提示、错误提示、警告提示等。 使用方法: 在需要使用u-message组件的页面引入组件,并在页面注册使用u-message组件。 ```vue <template> <view> <u-message ref="message" /> </view> </template> <script> import { uMessage } from 'uview-ui'; export default { components: { uMessage } } </script> ``` 在需要触发u-message消息提示的事件,调用u-message组件的show方法来显示提示信息。 ```javascript this.$refs.message.show({ type: 'success', title: '提示', content: '操作成功' }); ``` 其,type表示提示信息的类型,可以为success、error、warning等,title表示提示信息的标题,content表示提示信息的内容。 3. u-modal组件 u-modal组件是一种弹窗组件,可以用来显示比较复杂的提示信息,包括确认框、提示框、输入框等。 使用方法: 在需要使用u-modal组件的页面引入组件,并在页面注册使用u-modal组件。 ```vue <template> <view> <u-modal ref="modal" /> </view> </template> <script> import { uModal } from 'uview-ui'; export default { components: { uModal } } </script> ``` 在需要触发u-modal消息提示的事件,调用u-modal组件的show方法来显示提示信息。 ```javascript this.$refs.modal.show({ title: '提示', content: '确定要删除吗?', showCancel: true, confirmText: '确定', cancelText: '取消', confirm: () => { console.log('点击了确定按钮'); }, cancel: () => { console.log('点击了取消按钮'); } }); ``` 其,title表示提示信息的标题,content表示提示信息的内容,showCancel表示是否显示取消按钮,confirmText表示确定按钮的文本,cancelText表示取消按钮的文本,confirm表示点击确定按钮时执行的回调函数,cancel表示点击取消按钮时执行的回调函数。 以上就是uview常用的三种消息提示组件的使用方法,希望对你有所帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq_2524963996

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值