Skip to content

Commit

Permalink
fix: 修复pi-list 属性设置无效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhenfei committed Nov 17, 2020
1 parent e5a4942 commit 1565626
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
18 changes: 10 additions & 8 deletions components/pi-list-item/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<view
class="pi-list-item pi-align-center"
:hover-class="hoverClass"
:hover-class="getHoverClass"
:style="[customStyle, itemStyle]"
:class="[{ border: getBorder }, customClass]"
:hover-start-time="hoverStartTime"
Expand Down Expand Up @@ -39,13 +39,16 @@
</template>

<script>
import { childInit } from '../../mixin/props-sync'
import { getConfig } from '../../config'
const TAG = 'PiListItem'
const { listItem } = getConfig()
const extendPiList = childInit('List')
export default {
name: 'ListItem',
mixins: [extendPiList], // 注入value与val,进行双向绑定
props: {
// 自定义样式,对象形式(默认值:{})
customStyle: {
Expand Down Expand Up @@ -210,12 +213,14 @@ export default {
},
computed: {
getBorder() {
return this.piList ? this.piList.border : this.border
return this.inheritProps.border || this.border
},
getHeight() {
return this.$pi.common.addUnit(
this.piList && this.piList.height ? this.piList.height : this.height
)
const height = this.inheritProps.height || this.height
return this.$pi.common.addUnit(height)
},
getHoverClass() {
return this.inheritProps.hoverClass || this.hoverClass
},
itemStyle() {
const style = {
Expand All @@ -225,9 +230,6 @@ export default {
return style
}
},
inject: {
piList: { default: undefined }
},
created() {},
methods: {
handleItemClick(e) {
Expand Down
9 changes: 9 additions & 0 deletions components/pi-list/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
</template>

<script>
import { parentInit } from '../../mixin/props-sync'
import { getConfig } from '../../config'
const TAG = 'PiList'
const { list } = getConfig()
export default {
name: 'List',
mixins: [parentInit(['height', 'border', 'hoverClass'])],
props: {
// 自定义样式,对象形式(默认值:{})
customStyle: {
Expand All @@ -34,6 +36,13 @@ export default {
return list.customClass
}
},
// 列表高度
height: {
type: [String, Number],
default() {
return list.height
}
},
// 列表面板标题
title: {
type: String,
Expand Down
4 changes: 3 additions & 1 deletion config/list.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export default {
customClass: '', // 自定义样式类,字符串形式('')
customStyle: {}, // 自定义样式,对象形式(默认值:{})
height: undefined, // 列表项高度
title: '', // 列表面板标题
titleStyle: {}, // 标题自定义样式,对象形式(默认值:{})
disabled: false, // 是否禁用
border: true // 是否显示边框
border: true, // 是否显示边框
hoverClass: undefined // 宫格按压时的样式类,"none"为无效果
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sadais-piui",
"version": "1.0.11",
"version": "1.0.13",
"description": "piui组件库",
"main": "index.js",
"scripts": {
Expand Down
5 changes: 2 additions & 3 deletions tools/navi.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ const _openInterceptor = (method, url, params) => {
url,
complete: res => {
routing = false
const isSuccess = res.errMsg && res.errMsg.indexOf(':ok') !== -1
if (isSuccess) resolve(res)
else reject(res)
const isSuccess = res.errMsg && res.errMsg.includes(':ok')
isSuccess ? resolve(res) : reject(res)
}
})
})
Expand Down

0 comments on commit 1565626

Please sign in to comment.