naive-ui/demo/utils/EditOnGithubButton.vue

55 lines
861 B
Vue
Raw Normal View History

2020-03-19 13:26:06 +08:00
<template>
<n-button
class="edit-button"
ghost
round
2020-03-19 18:26:48 +08:00
:size="size"
:text="text"
2020-03-19 13:26:06 +08:00
@click="handleEditOnGithubClick"
>
<template v-slot:icon>
2020-05-30 16:13:09 +08:00
<edit-icon />
2020-03-19 13:26:06 +08:00
</template>
</n-button>
</template>
2020-03-19 18:26:48 +08:00
2020-03-19 13:26:06 +08:00
<script>
2020-05-31 00:57:47 +08:00
import editIcon from '../../src/_icons/git-commit-outline'
2020-03-19 18:26:48 +08:00
2020-03-19 13:26:06 +08:00
export default {
name: 'EditOnGithubButton',
components: {
2020-05-30 16:13:09 +08:00
editIcon
2020-03-19 13:26:06 +08:00
},
props: {
url: {
type: String,
required: true
2020-03-19 18:26:48 +08:00
},
text: {
type: Boolean,
default: false
},
size: {
type: String,
default: undefined
2020-03-19 13:26:06 +08:00
}
},
data () {
return {
gheUrl: 'https://***REMOVED***/tree/develop/'
}
},
computed: {
gheDocUrl () {
return this.gheUrl + this.url
}
},
methods: {
handleEditOnGithubClick () {
2020-03-19 13:34:13 +08:00
window.open(this.gheDocUrl, '_blank')
2020-03-19 13:26:06 +08:00
}
}
}
</script>