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> </div>
</template> </template>
<script> <script lang="ts">
export default { import { defineComponent, computed, PropType } from 'vue'
import { Entity } from 'megalodon'
import { useRouter, useRoute } from 'vue-router'
export default defineComponent({
name: 'tag', name: 'tag',
props: { props: {
tag: { tag: {
type: Object, type: Object as PropType<Entity.Tag>,
default: null, 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> </script>
<style lang="scss" scoped> <style lang="scss" scoped>