uniapp基本教程、uView的使用

忽然想研究uniapp了,认真了研究了一下,发现构建项目都好麻烦,就出一个教程防止大家踩坑‘

一、我们先构建一个自己的uniapp空项目

在这里插入图片描述

二、接着去找模板

支持vue2 uview集成库:
支持vue2,vue3 uview集成库
在这边我演示的是第一个集成库
在这里插入图片描述
下载次数还是比较多得哦
在这里插入图片描述
选择这个集成进去、就会出现这个页面,然后选择你对应的项目就可以 直接集成进去,然后再去操作下面流程
在这里插入图片描述

三、使用uview

1、main.js导入
// 在import Vue from 'vue'下面引入
import uView from '@/uni_modules/uview-ui'
Vue.use(uView)
2、在uni.scss导入
@import '@/uni_modules/uview-ui/theme.scss';

3、在App.vue导入
<style lang="scss">
		// / 注意要写在第一行,同时给style标签加入lang="scss"属性 */
		@import "@/uni_modules/uview-ui/index.scss"
</style>
4、在pages.json导入
"easycom": {
	    "^u-(.*)": "@/uni_modules/uview-ui/components/u-$1/u-$1.vue"
	},

到这里基本上就配置完整了,我们就可以启动项目进行测试了

四、展示结果

1、页面代码
<template>
	<view class="content">
		<u-popup :show="show" @close="close" @open="open">
			<view>
				<text>出淤泥而不染,濯清涟而不妖</text>
				<view class="">
					我在这
				</view>
				<text>出淤泥而不染,濯清涟而不妖</text>
				<view class="">
					我在这
				</view>
				<text>出淤泥而不染,濯清涟而不妖</text>
				<view class="">
					我在这
				</view>
				<text>出淤泥而不染,濯清涟而不妖</text>
				<view class="">
					我在这
				</view>
				<text>出淤泥而不染,濯清涟而不妖</text>
				<view class="">
					我在这
				</view>
				<text>出淤泥而不染,濯清涟而不妖</text>
				<view class="">
					我在这
				</view>
				<text>出淤泥而不染,濯清涟而不妖</text>
				<view class="">
					我在这
				</view>
				<text>出淤泥而不染,濯清涟而不妖</text>
				<view class="">
					我在这
				</view>
			</view>
		</u-popup>
		<u-button @click="show = true">打开</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				show: false
			}
		},
		onLoad() {

		},
		methods: {
			open() {
				// console.log('open');
			},
			close() {
				this.show = false
				// console.log('close');
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
2、效果图

在这里插入图片描述

踩坑:注意如果出现报错等情况,记得重启项目

  • 10
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值