Record the problems encountered in the development of a small program (uniapp+uview) (continuously updated)

Every time you develop a small program, you will encounter various problems. But some problems have already been encountered, but when they are encountered, they still have to ask Du Niang in various ways. This article is hereby published for the convenience of myself and everyone.

for reference only

1. The style of u-collapse is normal in h5, but the style is messed up in the WeChat applet?

reason:
insert image description here

Solution:
don't use the wording of slot, but there will be a modification of the style . The modification method of the style is as follows.

//   /deep/是深度,  !important是最高的优先级   
//   这个类名怎么找?  在浏览器中 按F12, 找到左上角箭头,点击你要修改的, 就会出现你要修改的类名,具体可以私信我, 我教你。  u-icon__icon 左侧图标   u-cell__title-text 左侧标题
/deep/ .u-icon__icon{
    
    
	font-weight: bold !important;
}

2. 报错:It‘s not allowed to load an initial chunk on demand. The chunk name “XXX”

uniapp runs to the WeChat applet and reports an error.
Reason: The page named XXX is a component and does not need to be registered in pages.json.

Solution: Delete XXX in pages.json.

As shown in the picture:
insert image description here

3. transition is invalid in WeChat Mini Program

.opencs{
    
    
	transition: 300ms;
	transform: rotate(90deg);
}

Reason: transform is invalid for inline elements in the WeChat applet (my own understanding may be wrong, but I solved it).

Solution: It can be solved by nesting a block element in the outer layer.

4. Jump with parameters between uniapp pages, for example, A jumps to B with parameters, this parameter can be printed in A, but B can’t receive it?

原因: A带的是个object的参数,B中接收不到。

解决办法:
  //这是a页面   先把对象转化为json的字符串
	uni.navigateTo({
    
    
			url: "/pages/order/orderInfo?item="+ encodeURIComponent(JSON.stringify(你的参数))
		})
 //这是b页面
	onload(option){
    
    
		//	  此时的 a 就是你从a带过来的参数,并且是个对象
		that.a = JSON.parse(decodeURIComponent(option.item))
	}
	

5. Upload your own code to git

git add .
git commit -m "20230308"
git pull origin master
git push origin master

6. When uniapp uses the timeAlert component, when the component is closed, the background color will flash on the full screen (when your background color is not white).

insert image description here
insert image description here

Reason: Your background color is not the same color as the mask layer.

Solution: Get the background color of your page and convert it to rgba. In the css style of the component, give it a transparent color, so that the screen will not flash as a whole visually.

.appintAlertMask {
    
    
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	top: 0;
	// 获取你页面的背景颜色,转化为rgba,background-color给你转化过的透明色,视觉上就不会出现屏幕整体闪一下的感觉
	background-color: rgba(241,241,241, 0.7);
	z-index: -9999;
	opacity: 0;
	transition: opacity 0.3s;
}

7. The fontSize of the customStyle custom attribute of u-botton in uView has no effect.

错误代码:
<u-button text="取消订单" :customStyle="{fontSize: '25upx'}"></u-button>
正确代码:(把文本位置改动一下位置就可以)
<u-button :customStyle="{fontSize: '25upx'}">取消订单</u-button>

8. WeChat applet – turn off the [filter non-dependent files] function

insert image description here

If there are these two attributes, change them to false. If there are no these two attributes, add them

    "ignoreUploadUnusedFiles": false,
    "ignoreDevUnusedFiles": false

9. Convert string in java to entity class

// 字符串
String jsonStr = "[{"keyType":1,"keyArray":"0.00"},{"keyType":2,"keyArray":"0.00"}]";
JSONArray jsonArray = new JSONArray(jsonStr);    
List<KeyType> keyTypes = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); i++) {
    
    
    JSONObject jsonObject = jsonArray.getJSONObject(i);
    int keyType = jsonObject.getInt("keyType");
    String keyArray = jsonObject.getString("keyArray");
    keyTypes.add(new KeyType(keyType, keyArray));
}

  1. Get the playing

Guess you like

Origin blog.csdn.net/weixin_45729937/article/details/129388108