Card add to, replace, target, append prop
This commit is contained in:
parent
0264b7c4fd
commit
da404a1d3e
3 changed files with 32 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<Card style="width:350px">
|
<Card style="width:350px" to="/button">
|
||||||
<p slot="title">
|
<p slot="title">
|
||||||
<Icon type="ios-film-outline"></Icon>
|
<Icon type="ios-film-outline"></Icon>
|
||||||
<span>经典电影</span>
|
<span>经典电影</span>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="classes">
|
<component :is="tagName" :class="classes" v-bind="tagProps" @click="handleClickLink">
|
||||||
<div :class="headClasses" v-if="showHead"><slot name="title">
|
<div :class="headClasses" v-if="showHead"><slot name="title">
|
||||||
<p v-if="title">
|
<p v-if="title">
|
||||||
<Icon v-if="icon" :type="icon"></Icon>
|
<Icon v-if="icon" :type="icon"></Icon>
|
||||||
|
@ -8,15 +8,17 @@
|
||||||
</slot></div>
|
</slot></div>
|
||||||
<div :class="extraClasses" v-if="showExtra"><slot name="extra"></slot></div>
|
<div :class="extraClasses" v-if="showExtra"><slot name="extra"></slot></div>
|
||||||
<div :class="bodyClasses" :style="bodyStyles"><slot></slot></div>
|
<div :class="bodyClasses" :style="bodyStyles"><slot></slot></div>
|
||||||
</div>
|
</component>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
const prefixCls = 'ivu-card';
|
const prefixCls = 'ivu-card';
|
||||||
const defaultPadding = 16;
|
const defaultPadding = 16;
|
||||||
import Icon from '../icon/icon.vue';
|
import Icon from '../icon/icon.vue';
|
||||||
|
import mixinsLink from '../../mixins/link';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Card',
|
name: 'Card',
|
||||||
|
mixins: [ mixinsLink ],
|
||||||
components: { Icon },
|
components: { Icon },
|
||||||
props: {
|
props: {
|
||||||
bordered: {
|
bordered: {
|
||||||
|
@ -76,6 +78,31 @@
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// Point out if it should render as <a> tag
|
||||||
|
isHrefPattern () {
|
||||||
|
const { to } = this;
|
||||||
|
return !!to;
|
||||||
|
},
|
||||||
|
tagName () {
|
||||||
|
const { isHrefPattern } = this;
|
||||||
|
return isHrefPattern ? 'a' : 'div';
|
||||||
|
},
|
||||||
|
tagProps () {
|
||||||
|
const { isHrefPattern } = this;
|
||||||
|
if (isHrefPattern) {
|
||||||
|
const { linkUrl,target } = this;
|
||||||
|
return { href: linkUrl, target };
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleClickLink (event) {
|
||||||
|
if (!this.isHrefPattern) return;
|
||||||
|
const openInNewWindow = event.ctrlKey || event.metaKey;
|
||||||
|
this.handleCheckClick(event, openInNewWindow);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
@card-prefix-cls: ~"@{css-prefix}card";
|
@card-prefix-cls: ~"@{css-prefix}card";
|
||||||
|
|
||||||
.@{card-prefix-cls}{
|
.@{card-prefix-cls}{
|
||||||
|
display: block;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: @border-radius-small;
|
border-radius: @border-radius-small;
|
||||||
font-size: @font-size-base;
|
font-size: @font-size-base;
|
||||||
|
@ -47,4 +48,4 @@
|
||||||
&-body {
|
&-body {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue