Skip to content

Commit a2acf7e

Browse files
committed
1. 修复在nvue下样式的警告和报错问题
2. 修复grid组件在头条小程序的报错的问题 3. 优化tabs组件在头条小程序的表现问题 4. 修复index-list组件在头条小程序上的兼容性 5. 修复layout组件在头条小程序上的兼容性 6. 修复table组件在头条小程序上的兼容性 7. 修复checkbox组件在头条小程序上的兼容性 8. 修复radio组件在头条小程序上的兼容性
1 parent 5322f84 commit a2acf7e

File tree

22 files changed

+215
-249
lines changed

22 files changed

+215
-249
lines changed

pages.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@
547547
"path": "navbar/index",
548548
"style": {
549549
// "navigationBarTitleText": "navbar-自定义导航栏",
550-
"navigationStyle": "custom" ,// 隐藏系统导航栏
550+
"navigationStyle": "custom", // 隐藏系统导航栏
551551
"navigationBarTextStyle": "white" // 状态栏字体为白色
552552
}
553553
},
@@ -758,13 +758,16 @@
758758
"style": {
759759
"navigationBarTitleText": "upload-上传"
760760
}
761-
}, // waterfall瀑布流
761+
},
762+
// waterfall瀑布流
763+
// #ifndef MP-TOUTIAO
762764
{
763765
"path": "waterfall/index",
764766
"style": {
765767
"navigationBarTitleText": "waterfall-瀑布流"
766768
}
767769
},
770+
// #endif
768771
// table表格
769772
{
770773
"path": "table/index",

pages/componentsB/radio/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@
121121
},
122122
// 选中某个单选框时,由radio时触发
123123
radioChange(e) {
124-
console.log(e);
124+
//console.log(e);
125125
},
126126
// 选中任一radio时,由radio-group触发
127127
radioGroupChange(e) {
128128
this.result = e;
129-
console.log(e);
129+
//console.log(e);
130130
},
131131
widthChange(index) {
132132
this.width = index == 0 ? '50%' : '';

pages/componentsB/table/index.vue

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@
55
<view class="u-demo-area">
66
<u-toast ref="uToast"></u-toast>
77
<u-table :align="align" :borderColor="borderColor">
8-
<u-tr>
9-
<u-th>姓名</u-th>
10-
<u-th>年龄</u-th>
11-
<u-th>籍贯</u-th>
12-
<u-th>性别</u-th>
8+
<u-tr class="u-tr">
9+
<u-th class="u-th">姓名</u-th>
10+
<u-th class="u-th">年龄</u-th>
11+
<u-th class="u-th">籍贯</u-th>
12+
<u-th class="u-th">性别</u-th>
1313
</u-tr>
14-
<u-tr>
15-
<u-td>吕布</u-td>
16-
<u-td>22</u-td>
17-
<u-td>楚河</u-td>
18-
<u-td>男</u-td>
14+
<u-tr class="u-tr">
15+
<u-td class="u-td">吕布</u-td>
16+
<u-td class="u-td">22</u-td>
17+
<u-td class="u-td">楚河</u-td>
18+
<u-td class="u-td">男</u-td>
1919
</u-tr>
20-
<u-tr>
21-
<u-td>项羽</u-td>
22-
<u-td>28</u-td>
23-
<u-td>汉界</u-td>
24-
<u-td>男</u-td>
20+
<u-tr class="u-tr">
21+
<u-td class="u-td">项羽</u-td>
22+
<u-td class="u-td">28</u-td>
23+
<u-td class="u-td">汉界</u-td>
24+
<u-td class="u-td">男</u-td>
2525
</u-tr>
26-
<u-tr>
27-
<u-td>木兰</u-td>
28-
<u-td>24</u-td>
29-
<u-td>南国</u-td>
30-
<u-td>女</u-td>
26+
<u-tr class="u-tr">
27+
<u-td class="u-td">木兰</u-td>
28+
<u-td class="u-td">24</u-td>
29+
<u-td class="u-td">南国</u-td>
30+
<u-td class="u-td">女</u-td>
3131
</u-tr>
3232
</u-table>
3333
</view>

pages/componentsC/collapse/index.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<view class="u-demo-title">演示效果</view>
55
<view class="u-demo-area">
66
<u-toast ref="uToast"></u-toast>
7-
<u-collapse :item-style="itemStyle" event-type="close" :arrow="arrow" :accordion="accordion" @change="change">
7+
<u-collapse v-if="key" :item-style="itemStyle" event-type="close" :arrow="arrow" :accordion="accordion" @change="change">
88
<u-collapse-item :index="index" @change="itemChange" :title="item.head" v-for="(item, index) in itemList" :key="index">
99
{{item.body}}
1010
</u-collapse-item>
@@ -59,7 +59,8 @@
5959
accordion: true,
6060
arrow: true,
6161
hoverClass: 'hover2',
62-
itemStyle: {}
62+
itemStyle: {},
63+
key: true
6364
}
6465
},
6566
methods: {
@@ -68,6 +69,7 @@
6869
},
6970
arrowChange(index) {
7071
this.arrow = index == 0 ? true : false;
72+
this.changeStatus();
7173
},
7274
styleChange(index) {
7375
if(index == 0) {
@@ -79,6 +81,7 @@
7981
} else {
8082
this.itemStyle = {}
8183
}
84+
this.changeStatus();
8285
},
8386
change(index) {
8487
let str = '';
@@ -97,6 +100,12 @@
97100
},
98101
itemChange(e) {
99102
console.log(e);
103+
},
104+
changeStatus() {
105+
this.key = false;
106+
this.$nextTick(function(){
107+
this.key = true;
108+
})
100109
}
101110
}
102111
}

pages/componentsC/grid/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@
8888
<view class="u-config-title u-border-bottom">
8989
参数配置
9090
</view>
91-
<view class="u-config-item">
91+
<!-- <view class="u-config-item">
9292
<view class="u-item-title">是否显示边框</view>
9393
<u-subsection vibrateShort :list="['是', '否']" @change="borderChange"></u-subsection>
94-
</view>
94+
</view> -->
9595
<view class="u-config-item">
9696
<view class="u-item-title">是否可滑动</view>
9797
<u-subsection vibrateShort current="1" :list="['是', '否']" @change="isSwiperChange"></u-subsection>

pages/componentsC/layout/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<view class="u-demo-wrap">
44
<view class="u-demo-title">演示效果</view>
55
<view class="u-demo-area">
6-
<u-row gutter="20" :justify="justify">
6+
<u-row :justify="justify">
77
<u-col :span="span" :offset="offset" @click="click">
88
<view class="demo-layout bg-purple-dark">
99

uview-ui/components/u-checkbox/u-checkbox.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<view class="u-checkbox" :style="[checkboxStyle]">
33
<view class="u-checkbox__icon-wrap" @tap="toggle" :class="[iconClass]" :style="[iconStyle]">
4-
<u-icon name="checkbox-mark" :size="checkboxIconSize" :color="iconColor"/>
4+
<u-icon class="u-checkbox__icon-wrap__icon" name="checkbox-mark" :size="checkboxIconSize" :color="iconColor"/>
55
</view>
66
<view class="u-checkbox__label" @tap="onClickLabel" :style="{
77
fontSize: $u.addUnit(labelSize)
@@ -213,7 +213,9 @@
213213
@import "../../libs/css/style.components.scss";
214214
215215
.u-checkbox {
216+
/* #ifndef APP-NVUE */
216217
display: inline-flex;
218+
/* #endif */
217219
align-items: center;
218220
overflow: hidden;
219221
user-select: none;
@@ -236,6 +238,13 @@
236238
border: 1px solid #c8c9cc;
237239
transition-duration: 0.2s;
238240
241+
/* #ifdef MP-TOUTIAO */
242+
// 头条小程序兼容性问题,需要设置行高为0,否则图标偏下
243+
&__icon {
244+
line-height: 0;
245+
}
246+
/* #endif */
247+
239248
&--circle {
240249
border-radius: 100%;
241250
}

uview-ui/components/u-col/u-col.vue

Lines changed: 16 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,21 @@
5252
default: 'left'
5353
}
5454
},
55-
inject: ['gutter'],
55+
data() {
56+
return {
57+
gutter: 20, // 给col添加间距,左右边距各占一半,从父组件u-row获取
58+
}
59+
},
60+
created() {
61+
this.parent = false;
62+
},
63+
mounted() {
64+
// 获取父组件实例,并赋值给对应的参数
65+
this.parent = this.$u.$parent.call(this, 'u-row');
66+
if(this.parent) {
67+
this.gutter = this.parent.gutter;
68+
}
69+
},
5670
computed: {
5771
uJustify() {
5872
if (this.justify == 'end' || this.justify == 'start') return 'flex-' + this.justify;
@@ -76,60 +90,8 @@
7690
<style lang="scss">
7791
@import "../../libs/css/style.components.scss";
7892
.u-col {
79-
/* #ifdef MP-WEIXIN || MP-QQ */
93+
/* #ifdef MP-WEIXIN || MP-QQ || MP-TOUTIAO */
8094
float: left;
8195
/* #endif */
8296
}
83-
84-
.u-col-0 {
85-
width: 0;
86-
}
87-
88-
.u-col-1 {
89-
width: calc(100%/12);
90-
}
91-
92-
.u-col-2 {
93-
width: calc(100%/12 * 2);
94-
}
95-
96-
.u-col-3 {
97-
width: calc(100%/12 * 3);
98-
}
99-
100-
.u-col-4 {
101-
width: calc(100%/12 * 4);
102-
}
103-
104-
.u-col-5 {
105-
width: calc(100%/12 * 5);
106-
}
107-
108-
.u-col-6 {
109-
width: calc(100%/12 * 6);
110-
}
111-
112-
.u-col-7 {
113-
width: calc(100%/12 * 7);
114-
}
115-
116-
.u-col-8 {
117-
width: calc(100%/12 * 8);
118-
}
119-
120-
.u-col-9 {
121-
width: calc(100%/12 * 9);
122-
}
123-
124-
.u-col-10 {
125-
width: calc(100%/12 * 10);
126-
}
127-
128-
.u-col-11 {
129-
width: calc(100%/12 * 11);
130-
}
131-
132-
.u-col-12 {
133-
width: calc(100%/12 * 12);
134-
}
13597
</style>

uview-ui/components/u-collapse-item/u-collapse-item.vue

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,58 +80,53 @@
8080
default: ''
8181
}
8282
},
83-
inject: ['uCollapse'],
8483
data() {
8584
return {
8685
isShow: false,
8786
elId: this.$u.guid(),
8887
height: 0, // body内容的高度
8988
headStyle: {}, // 头部样式,对象形式
9089
bodyStyle: {}, // 主体部分样式
91-
//itemStyle: {}, // 每个item的整体样式
90+
itemStyle: {}, // 每个item的整体样式
9291
arrowColor: '', // 箭头的颜色
9392
hoverClass: '', // 头部按下时的效果样式类
93+
arrow: true, // 是否显示右侧箭头
94+
9495
};
9596
},
96-
mounted() {
97-
this.init();
98-
},
9997
watch: {
10098
open(val) {
10199
this.isShow = val;
102100
}
103101
},
104-
computed: {
105-
arrow() {
106-
return this.uCollapse.arrow;
107-
},
108-
itemStyle() {
109-
return this.uCollapse.itemStyle;
110-
}
111-
},
112102
created() {
103+
this.parent = false;
113104
// 获取u-collapse的信息,放在u-collapse是为了方便,不用每个u-collapse-item写一遍
114105
this.isShow = this.open;
115-
this.nameSync = this.name ? this.name : this.uCollapse.childrens.length;
116-
this.uCollapse.childrens.push(this);
117-
//this.itemStyle = this.uCollapse.itemStyle;
118-
this.headStyle = this.uCollapse.headStyle;
119-
this.bodyStyle = this.uCollapse.bodyStyle;
120-
this.arrowColor = this.uCollapse.arrowColor;
121-
this.hoverClass = this.uCollapse.hoverClass;
122106
},
123107
methods: {
124108
// 异步获取内容,或者动态修改了内容时,需要重新初始化
125109
init() {
110+
this.parent = this.$u.$parent.call(this, 'u-collapse');
111+
if(this.parent) {
112+
this.nameSync = this.name ? this.name : this.parent.childrens.length;
113+
this.parent.childrens.push(this);
114+
this.headStyle = this.parent.headStyle;
115+
this.bodyStyle = this.parent.bodyStyle;
116+
this.arrowColor = this.parent.arrowColor;
117+
this.hoverClass = this.parent.hoverClass;
118+
this.arrow = this.parent.arrow;
119+
this.itemStyle = this.parent.itemStyle;
120+
}
126121
this.$nextTick(() => {
127122
this.queryRect();
128123
});
129124
},
130125
// 点击collapsehead头部
131126
headClick() {
132127
if (this.disabled) return;
133-
if (this.uCollapse.accordion == true) {
134-
this.uCollapse.childrens.map(val => {
128+
if (this.parent && this.parent.accordion == true) {
129+
this.parent.childrens.map(val => {
135130
// 自身不设置为false,因为后面有this.isShow = !this.isShow;处理了
136131
if (this != val) {
137132
val.isShow = false;
@@ -146,7 +141,7 @@
146141
show: this.isShow
147142
})
148143
// 只有在打开时才发出事件
149-
if (this.isShow) this.uCollapse.onChange();
144+
if (this.isShow) this.parent && this.parent.onChange();
150145
this.$forceUpdate();
151146
},
152147
// 查询内容高度
@@ -157,6 +152,9 @@
157152
this.height = res.height;
158153
})
159154
}
155+
},
156+
mounted() {
157+
this.init();
160158
}
161159
};
162160
</script>

uview-ui/components/u-collapse/u-collapse.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@
6363
default: 'u-hover-class'
6464
}
6565
},
66-
provide() {
67-
return {
68-
uCollapse: this
69-
}
70-
},
7166
created() {
7267
this.childrens = []
7368
},

0 commit comments

Comments
 (0)