tree组件增加多选开关;优化:attr指令逻辑
parent
65ac216f91
commit
7784e87511
|
@ -3723,16 +3723,22 @@
|
|||
if (!W3C && propMap[k]) {
|
||||
k = propMap[k]
|
||||
}
|
||||
if (obj[i] === false || obj[i] === null || obj[i] === undefined) {
|
||||
obj[i] = ''
|
||||
}
|
||||
|
||||
if (typeof elem[boolMap[k]] === 'boolean') {
|
||||
//布尔属性必须使用el.xxx = true|false方式设值
|
||||
elem[boolMap[k]] = !!obj[i]
|
||||
|
||||
//如果为false, IE全系列下相当于setAttribute(xxx, ''),会影响到样式,需要进一步处理
|
||||
if (!obj[i]) obj[i] = !!obj[i]
|
||||
if (!obj[i]) {
|
||||
obj[i] = !!obj[i]
|
||||
}
|
||||
if (obj[i] === false || obj[i] === null || obj[i] === undefined)
|
||||
if (obj[i] === false) {
|
||||
return elem.removeAttribute(k)
|
||||
}
|
||||
}
|
||||
|
||||
//SVG只能使用setAttribute(xxx, yyy), VML只能使用elem.xxx = yyy ,HTML的固有属性必须elem.xxx = yyy
|
||||
var isInnate = rsvg.test(elem)
|
||||
|
|
|
@ -44,6 +44,7 @@ export default Anot.component('tree', {
|
|||
<em class="ui-font" :click="toggle(el)"></em>
|
||||
<span
|
||||
class="checkbox ui-font"
|
||||
:if="multiCheck"
|
||||
:class="{checked: el.checked}"
|
||||
:click="onChecked(el)"></span>
|
||||
<span
|
||||
|
@ -53,13 +54,14 @@ export default Anot.component('tree', {
|
|||
<template
|
||||
name="tree"
|
||||
:attr="{
|
||||
'multi-check': multiCheck,
|
||||
list: el[props.children],
|
||||
onSelected: props.onSelected,
|
||||
onChecked: onChecked,
|
||||
id: props.id,
|
||||
label: props.label,
|
||||
parent: props.parent,
|
||||
children: props.children
|
||||
children: props.children,
|
||||
}"></template>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -72,8 +74,10 @@ export default Anot.component('tree', {
|
|||
props.parent = props.parent || 'parent'
|
||||
props.children = props.children || 'children'
|
||||
state.list = format(props.list || [], props)
|
||||
state.multiCheck = !!props.multiCheck
|
||||
delete props.list
|
||||
delete props.theme
|
||||
delete props.multiCheck
|
||||
},
|
||||
componentDidMount: function() {
|
||||
if (typeof this.props.onCreated === 'function') {
|
||||
|
@ -82,16 +86,17 @@ export default Anot.component('tree', {
|
|||
},
|
||||
state: {
|
||||
list: [],
|
||||
multiCheck: false,
|
||||
currItem: -1,
|
||||
checked: {}
|
||||
},
|
||||
skip: ['checked'],
|
||||
props: {
|
||||
className: '',
|
||||
id: 'id',
|
||||
label: 'label',
|
||||
parent: 'parent',
|
||||
children: 'children',
|
||||
id: '',
|
||||
label: '',
|
||||
parent: '',
|
||||
children: '',
|
||||
onCreated: Anot.PropsTypes.isFunction(),
|
||||
onSelected: Anot.PropsTypes.isFunction(),
|
||||
onChecked: Anot.PropsTypes.isFunction()
|
||||
|
|
Reference in New Issue