uni-app

本文详细介绍了uni-app的实战应用,包括input框的属性、uni-app的独特之处、网络请求的方法、数据缓存操作、图片上传和预览、跨端兼容的条件编译、导航跳转与参数传递、组件的创建和生命周期、button的不同状态、组件间通信及uni UI组件和地图及拨打电话功能的使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

uni-app

  • input框的一些属性
  • uni-app里不一样的地方
  • 发起网络请求 $myRequest方法挂载到全局
  • 数据缓存
  • 图片的上传和预览
  • 条件编译跨端兼容
  • 导航跳转和传参
  • 两种方法导航跳转和传参
  • 组件的创建使用和组件的生命周期函数
  • button的三个属性 primary default warn
  • 组件之间的通迅方式
  • map组件和 uni.makePhoneCall()的使用

input框的一些属性

常用的并且能为大多数浏览器所识别的类型大概有:text、password、number、
    button、reset、submit、hidden、radio、checkbox、file、image、
    color、range、date、month、week、time、datetime-local。
另外还有一些类型:tel、email、url、datetime、search。这些类型部分浏览器不支持识别或校验。

uni-app里不一样的地方

selectable   //是否选中
space="ensp"      //空格    字符里的空格就显示出来了
space="emsp"      //相当于中文字符的一个字符
space="nbsp"      //也是相当于一个中字


hover-class="box"     //相当于css里的hover 属性
hover-stop-propagation   //阻止冒泡
:hover-start-time      //相当于一个计时器
:hover-stay-time      //相当于一个计时器

button按钮组件使用  
<button>按钮</button>
<button size="mini">按钮</button>
<button type="primary">按钮</button>
<button type="primary" plain>按钮</button>
loading

image的一些属性
<image src="" mode="aspectFill"  mode="aspectFit"></image>


css
<style>
//以这种方式引入css
    @import url("./a.css")
</style>


uni-app的生命周期

页面触底
onReachBottom(){
    console.log('触底了')
    this.pageindex++
    this.getGoodsList()
}

下拉刷新
第一种方法:
uni.startPullDownRefresh(){}
第二种方法:
onPullDownRefresh:function(){
	console.log("触发了 刷新")
	uni.stopPullDownRefresh()   //执行完毕后停止刷新
},


//也可以写在 定时器里面
setTimeout(()=>{
	console.log("触发了 刷新")
	uni.stopPullDownRefresh()
},2000)

发起网络get请求 $myRequest方法挂载到全局

全部写在  methods里
return里定义一个    swiper:[]

index>index.vue>javascript
onLoad(){
    this.getSwipers()
}
methods:{
    getSwipers(){
    //获取轮播图的数据 数据链接
        uni:request({
            url:"",
            success:res=>{
                console.log(res)
                if(res.data.status !== 0){
                    return uni.showToast({
                        title:'获取数据失败'
                        
                    })
                }
            }
            this.swipers = res.data.message  
        })
    }
}
<!--第二种方法-->
methods:{
<!--获取轮播图的数据-->
    async getSwipers(){
        const res = await uni.request({
            url:'http://localhost:8082/api/getlunbo'
            
        })
        <!--console.log(res)   /
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值