fix(components): [link] add target attribute and relevant docs (#15266)

* fix(components): [link] add target attribute and relevant docs

* fix(components): [link] add target attribute and relevant docs

Update the type of the target attribute
This commit is contained in:
zepeng 2023-12-30 18:41:38 +08:00 committed by GitHub
parent a5b5dc7b20
commit ff7f80d941
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -63,6 +63,7 @@ link/with-icon
| underline | whether the component has underline | ^[boolean] | true |
| disabled | whether the component is disabled | ^[boolean] | false |
| href | same as native hyperlink's `href` | ^[string] | — |
| target | same as native hyperlink's `target` | ^[enum]`'_blank' \| '_parent' \| '_self' \| '_top'` | _self |[string] | — |
| icon | icon component | ^[string] / ^[Component] | — |
### Slots

View File

@ -1,5 +1,5 @@
import { buildProps, iconPropType } from '@element-plus/utils'
import type { ExtractPropTypes } from 'vue'
import type { ExtractPropTypes, PropType } from 'vue'
import type Link from './link.vue'
export const linkProps = buildProps({
@ -26,6 +26,13 @@ export const linkProps = buildProps({
* @description same as native hyperlink's `href`
*/
href: { type: String, default: '' },
/**
* @description same as native hyperlink's `target`
*/
target: {
type: String as PropType<'_blank' | '_parent' | '_self' | '_top' | string>,
default: '_self',
},
/**
* @description icon component
*/

View File

@ -2,6 +2,7 @@
<a
:class="linkKls"
:href="disabled || !href ? undefined : href"
:target="disabled || !href ? undefined : target"
@click="handleClick"
>
<el-icon v-if="icon"><component :is="icon" /></el-icon>