This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
cyber-narrator-cn-ui/src/Test.vue

37 lines
701 B
Vue
Raw Normal View History

2022-12-06 17:01:46 +08:00
<template>
<span test-id="count">{{count}}</span>
<span test-id="title">{{getData.title}}</span>
<button test-id="button" @click="click">click</button>
2022-12-06 17:01:46 +08:00
</template>
<script>
/* vue-jest的测试示例 */
import VueRouter from 'vue-router'
import axios from 'axios'
2022-12-06 17:01:46 +08:00
export default {
name: 'Test',
data () {
return {
count: 0,
getData: { id: 1, title: 'title' }
2022-12-06 17:01:46 +08:00
}
},
methods: {
click () {
this.count++
},
async getPosts () {
axios.get('/api/posts').then(response => {
this.getData = response.data
})
2022-12-06 17:01:46 +08:00
}
},
created () {
const { currentRoute } = VueRouter.useRouter()
return {
currentRoute
}
}
}
</script>