refs #3301 Rewrite molecules/Tag with composition API

This commit is contained in:
AkiraFukushima 2022-05-21 00:32:16 +09:00
parent fe1af9fbb4
commit e08191edc3
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
1 changed files with 23 additions and 14 deletions

View File

@ -9,24 +9,33 @@
</div>
</template>
<script>
export default {
<script lang="ts">
import { defineComponent, computed, PropType } from 'vue'
import { Entity } from 'megalodon'
import { useRouter, useRoute } from 'vue-router'
export default defineComponent({
name: 'tag',
props: {
tag: {
type: Object,
default: null,
},
type: Object as PropType<Entity.Tag>,
default: null
}
},
methods: {
openTag(tag) {
this.$router.push(`/${this.id()}/hashtag/${tag.name}`)
},
id() {
return this.$route.params.id
},
},
}
setup() {
const router = useRouter()
const route = useRoute()
const id = computed(() => route.params.id)
const openTag = (tag: Entity.Tag) => {
router.push(`/${id.value}/hashtag/${tag.name}`)
}
return {
openTag
}
}
})
</script>
<style lang="scss" scoped>