This commit is contained in:
tangjinzhou 2018-01-25 17:40:46 +08:00
parent ebc5d64604
commit fd31801281
9 changed files with 26 additions and 44 deletions

View File

@ -46,7 +46,7 @@ export function cloneVNodes (vnodes, deep) {
export function cloneElement (n, nodeProps, clone) {
const node = clone ? cloneVNode(n, true) : n
const { props = {}, key, on = {}, listeners = {}} = nodeProps
const { props = {}, key, on = {}} = nodeProps
const data = node.data || {}
const { style = data.style,
class: cls = data.class,
@ -58,9 +58,10 @@ export function cloneElement (n, nodeProps, clone) {
node.componentOptions.propsData = node.componentOptions.propsData || {}
node.componentOptions.listeners = node.componentOptions.listeners || {}
node.componentOptions.propsData = { ...node.componentOptions.propsData, ...props }
node.componentOptions.listeners = { ...node.componentOptions.listeners, ...listeners }
}
node.componentOptions.listeners = { ...node.componentOptions.listeners, ...on }
} else {
node.data.on = { ...(node.data.on || {}), ...on }
}
if (key !== undefined) {
node.key = key

View File

@ -73,7 +73,7 @@ export default {
},
},
render () {
const { htmlType, classes, disabled, handleClick, iconType, $slots, $attrs, _events } = this
const { htmlType, classes, disabled, handleClick, iconType, $slots, $attrs, $listeners } = this
const buttonProps = {
props: {
},
@ -84,14 +84,10 @@ export default {
},
class: classes,
on: {
...$listeners,
click: handleClick,
},
}
for (const [k, event] of Object.entries(_events)) {
if (!buttonProps.on[k]) {
buttonProps.on[k] = event
}
}
const needInserted = $slots.default && $slots.default.length === 1 && (!iconType || iconType === 'loading')
const kids = $slots.default && $slots.default.length === 1 ? this.insertSpace($slots.default[0], needInserted) : $slots.default
return (

View File

@ -29,6 +29,7 @@ export default {
if (this.clicked) {
return
}
this.clicked = true
clearTimeout(this.timeout)
this.timeout = setTimeout(() => (this.clicked = false), 500)
@ -36,9 +37,19 @@ export default {
},
},
render () {
const { title, classes, handleClick } = this
const { title, classes, handleClick, $listeners } = this
const iconProps = {
attrs: {
title,
},
class: classes,
on: {
...$listeners,
click: handleClick,
},
}
return (
<i title={title} class={classes} onClick={handleClick} />
<i {...iconProps}/>
)
},
beforeDestroy () {

View File

@ -162,7 +162,7 @@ export default {
...extraProps,
openChange: this.onOpenChange,
},
listeners: {
on: {
click: this.onClick,
itemHover: this.onItemHover,
openChange: this.onOpenChange,

View File

@ -4,21 +4,11 @@
## 箭头指向
设置了 `arrowPointAtCenter` 箭头将指向目标元素的中心
</md>
<Tooltip placement="topLeft" title="Prompt Text">
<a-tooltip placement="topLeft" title="Prompt Text">
<a-button>Align edge / 边缘对齐</a-button>
</Tooltip>
<Tooltip placement="topLeft" title="Prompt Text" arrowPointAtCenter>
</a-tooltip>
<a-tooltip placement="topLeft" title="Prompt Text" arrowPointAtCenter>
<a-button>Arrow points to center / 箭头指向中心</a-button>
</Tooltip>
</a-tooltip>
</div>
</template>
<script>
import { Tooltip, Button } from 'antd'
export default {
components: {
Tooltip,
},
}
</script>

View File

@ -493,13 +493,12 @@ export default {
props: {},
on: { _ANT_EVENT_HACK: () => {} },
key: 'trigger',
listeners: {},
}
if (this.isContextMenuToShow()) {
newChildProps.listeners.contextMenu = this.onContextMenu
newChildProps.on.contextMenu = this.onContextMenu
} else {
newChildProps.listeners.contextMenu = this.createTwoChains('contextMenu')
newChildProps.on.contextMenu = this.createTwoChains('contextMenu')
}
if (this.isClickToHide() || this.isClickToShow()) {

View File

@ -51,9 +51,6 @@ export default {
}
},
methods: {
test () {
console.log(122)
},
toggle () {
this.isOpen = !this.isOpen
},

View File

@ -64,7 +64,6 @@
"less": "^2.7.2",
"less-loader": "^4.0.5",
"markdown-it": "^8.4.0",
"markdown-it-anchor": "^4.0.0",
"marked": "^0.3.7",
"mocha": "^3.2.0",
"pre-commit": "^1.2.2",
@ -75,7 +74,6 @@
"style-loader": "^0.18.2",
"stylelint": "^8.1.1",
"stylelint-config-standard": "^17.0.0",
"transliteration": "^1.6.2",
"vue-antd-md-loader": "^1.0.2",
"vue-loader": "^13.0.5",
"vue-router": "^3.0.1",

View File

@ -1,5 +1,4 @@
const path = require('path')
const slugify = require('transliteration').slugify
const hljs = require('highlight.js')
const Token = require('markdown-it/lib/token')
const cheerio = require('cheerio')
@ -36,15 +35,6 @@ const renderHighlight = function (str, lang) {
} catch (err) {}
}
function wrap (render) {
return function (tokens) {
return render.apply(this, arguments)
.replace('<code class="', '<code class="hljs ')
.replace('<code>', '<code class="hljs">')
.replace('<pre>', '<pre class="code-section">')
}
};
const md = require('markdown-it')('default', {
html: true,
breaks: true,