fix: menu

This commit is contained in:
tangjinzhou 2020-06-20 15:14:51 +08:00
parent a53768fa9a
commit e60d535884
6 changed files with 45 additions and 22 deletions

View File

@ -195,15 +195,28 @@ const getAllProps = ele => {
if (ele.$) {
props = { ...props, ...this.$attrs };
} else {
props = { ...props, ...ele.props };
props = { ...ele.props, ...props };
}
return props;
};
// 使用 getOptionProps 替换 ,待测试
const getPropsData = ele => {
return getOptionProps(ele);
//return ele.props || {};
const getPropsData = vnode => {
const res = {};
const originProps = vnode.props || {};
const props = {};
Object.keys(originProps).forEach(key => {
props[camelize(key)] = originProps[key];
});
const options = vnode.type.props;
Object.keys(options).forEach(k => {
const v = resolvePropValue(options, props, k, props[k]);
if (k in props) {
// 仅包含 props不包含默认值
res[k] = v;
}
});
return res;
};
const getValueByProp = (ele, prop) => {
return getPropsData(ele)[prop];

View File

@ -3,15 +3,13 @@ import DropdownButton from './dropdown-button';
export { DropdownProps } from './dropdown';
export { DropdownButtonProps } from './dropdown-button';
import Base from '../base';
Dropdown.Button = DropdownButton;
/* istanbul ignore next */
Dropdown.install = function(Vue) {
Vue.use(Base);
Vue.component(Dropdown.name, Dropdown);
Vue.component(DropdownButton.name, DropdownButton);
Dropdown.install = function(app) {
app.component(Dropdown.name, Dropdown);
app.component(DropdownButton.name, DropdownButton);
};
export default Dropdown;

View File

@ -45,13 +45,14 @@ export default {
...tooltipProps,
placement: 'right',
overlayClassName: `${rootPrefixCls}-inline-collapsed-tooltip`,
children: (
};
return (
<Tooltip {...toolTipProps}>
{/* */}
<Item {...itemProps} ref="menuItem">
{getSlot(this)}
</Item>
),
};
// return <div>ddd</div>;
return <Tooltip {...toolTipProps}></Tooltip>;
</Tooltip>
);
},
};

View File

@ -1,17 +1,18 @@
<template>
<div>
<a-button @click="show = !show">按钮</a-button>
<a-tooltip class="ddddd" style="color: blue" v-if="show">
<template v-slot:title>prompt text</template>
<a-button class="test" style="color: red">Tooltip will show when mouse enter.</a-button>
</a-tooltip>
<demo />
</div>
</template>
<script>
import demo from '../antdv-demo/docs/menu/demo/horizontal';
export default {
components: {
demo,
},
data() {
return {
show: true,
current: ['mail'],
};
},
};

View File

@ -32,10 +32,20 @@ import Modal from 'ant-design-vue/modal';
import Menu from 'ant-design-vue/menu';
import 'ant-design-vue/style.js';
const basic = {
render() {
return this.$slots.default && this.$slots.default();
},
};
const app = createApp(App);
app.config.globalProperties.$notification = notification;
app.config.globalProperties.$message = message;
app
.component('demo-sort', { ...basic })
.component('md', { ...basic })
.component('api', { ...basic })
.component('CN', { ...basic })
.component('US', { ...basic })
.use(Avatar)
.use(Breadcrumb)
.use(Button)

View File

@ -12,7 +12,7 @@ module.exports = {
module: {
rules: [
{
test: /\.vue$/,
test: /\.(vue|md)$/,
loader: 'vue-loader',
},
{
@ -83,7 +83,7 @@ module.exports = {
'ant-design-vue': path.join(__dirname, './components'),
// vue$: 'vue/dist/vue.esm.js',
},
extensions: ['.js', '.jsx', '.vue'],
extensions: ['.js', '.jsx', '.vue', '.md'],
},
devServer: {
historyApiFallback: {