uniapp笔记

pages.json里的设置
1、style下的navigationBarTextStyle属性指的是顶部导航栏的返回键颜色,black(黑色)/white(白色)

uniapp的图片预览,例如arr=[图片1,图片2,…]

uni.previewImage({
	current:url,	//图片的当前链接	例:图片1
	urls:list	//该图片所在的图片列表,为数组 例:arr
})


uniapp在main.js里封装一个方法,然后在其他页面使用,并且获得这个方法的返回值

//main.js	
export default{
	data(){
		return{
			token:''
		}
	}
}
Vue.prototype.getSor=function(){
	//获取到token值
	let that=this
	uni.getStorage({	//在里面return结果为空,需要在外面return
		key: 'token_key',
		success: function(res) {
			if(res.data==''){
				that.token = ''
			}else{
				that.token = res.data
			}
		}
	});
	return that.token
}

//在需要使用到getSor()这个函数的页面
console.log(this.getSor());	//就能获得到返回的值

在html的style中使用动态数值(class也差不多一样的用法)

<!-- 模板字符串型,注意:样式要使用驼峰 -->
<view :style="{backgroundImage:`url(${barrageData.bg})`,top:`${statusBarHeight}px`}"></view>
<!-- 拼接型 -->
<view :style="{paddingTop:statusBarHeight + 'px',height:'calc(88rpx + 44px + ' +  statusBarHeight + 'px)'}"></view>
<!-- 三目运算型 -->
<view :style="index == 2 ?'height:608rpx':''"></view>
<view :style="{ height: index != 0 ? swiperHeight + 'rpx' : 'calc(100vh - 502rpx)' }"></view>
<!-- 赋值型 -->
<view :style="styleObj"></view>
export default{
	props:{
		styleObj:{
			type: Object,
			default: function () {
				return {}
			}
		}
	}
}
<!-- 赋值型,经过计算 -->
<view :style="[maskStyle, zoomStyle]"></view>
computed:{
	maskStyle(){
		let style = {};
		style.backgroundColor = "rgba(0, 0, 0, 0.6)";
		...
		return style;
	},
	zoomStyle(){
		...
	}
}

克隆数组

const arr = [1,2,3,4,5]
const clone = [].concat(arr)

let clone = JSON.parse(JSON.stringify(arr))
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值