• 项目常遇到的问题


    1:uniapp生成二维码

    	选择uQRCode插件
    	使用弹窗的功能将二维码弹出
    
    • 1
    • 2
    <uni-popup ref="popup" type="bottom">
    			<view class="popup-container">
    				<view class="popup-head">二维码
    					<image class="close-img" src="../../static/colse-icon.png" mode="heightFix" @click="closeCode">
    					</image>
    				</view>
    				<view class="popup-footer">
    					<view class="qr-box">
    						<uqrcode  canvas-id="qr" value="text" :options="options" size='248' sizeUnit='rpx'></uqrcode>
    					</view>
    					<view class="txt">请扫描</view>
    				</view>
    			</view>
    		</uni-popup>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    canvas-id=“qr”,value size sizeUnit 得需要设置

    然后在data里面配置

    options:{
    	code: 'https://qm.qq.com/cgi-bin/qm/qr?k=LKqML292dD2WvwQfAJXBUmvgbiB_TZWF&noverify=0',// 生成二维码的值
    	},
    
    • 1
    • 2
    • 3

    2:uniapp onShow接收参数

    onShow(){
        let allPages = getCurrentPages(); //获取当前页面栈的实例;
    	console.log(allPages);
    	let lastPages = allPages.length - 1; // 获得倒数第二个元素的索引;
    	console.log(lastPages);
    	let option = allPages[lastPages].options; // 获得上个页面传递的参数;
    	console.log(option);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    3:javascript如何获取对象的key和value

    Object.keys(obj)
    
    • 1

    在这里插入图片描述

    4:uni-app:页面直接传递复杂参数

    发送的页面

     const list = encodeURIComponent(JSON.stringify(item));
     // 转换为参数拼接到url中
     uni.navigateTo({
      url: '/pages/job/publish?item=' + list
     });
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    接受的页面

    onLoad(options) {
            // 此页面也可以用于新增 所以如果没有该值就跳转出去
    		if (!option.item) return;
     
    		const item = JSON.parse(decodeURIComponent(option.item));
            //后续对数据的处理
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    5:js对于数组元素相同的分类方法

    		list1:[
    			{id:1,name:'武汉',nr:'准一线'},
    			{id:1,name:'南京',nr:'准一线'},
    			{id:1,name:'长沙',nr:'准一线'}{id:1,name:'北京',nr:'一线'}{id:1,name:'上海',nr:'一线'}{id:1,name:'咸宁',nr:'十八线'}
    		]
    		   let map = {};
    		    let myArr = [];
    		    for(let i = 0; i < this.list1.length; i++){
    		      if(!map[this.list1[i].remark]){
    		        myArr.push({
    		          remark: this.list1[i].remark,
    		          data: [this.list1[i]]
    		        });
    		        map[this.list1[i].remark] = this.list1[i]
    		      } else {
    		        for(let j = 0; j < myArr.length; j++){
    		          if(this.list1[i].remark === myArr[j].remark){
    		            myArr[j].data.push(this.list1[i]);
    		            break
    		          }
    		        }
    		      }
    		    }
    			this.list1 = myArr
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    5:uniapp uni.navigeteBack后数据修改不渲染

    	payData.success = (res) => {
    	uni.showToast({
    		title: '支付成功',
    		success: () => {
    			setTimeout(() => {
    				uni.navigateBack();
    			}, 2000)
    		}
    	})
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    一定要先把数据线清空,不然数据不刷新

    onShow() {
    	this.orderList = []
    	this.currentPage = 1
    	this.gettradelist()
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
  • 相关阅读:
    关于Unity自带的保存简单且持久化数据PlayerPrefs类的使用
    JavaSE笔记(八)重制版
    【Vue组件化编程】
    要写论文了,怎么搞?
    【华为OD机试真题 JAVA】靠谱的车
    [Pandas技巧] 分组比例计算求和
    Git: 工作区、暂存区、本地仓库、远程仓库
    23个优秀开源免费BI仪表盘
    异步任务-线程池配置
    Kafka简单汇总
  • 原文地址:https://blog.csdn.net/qq_40281275/article/details/127939750