-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvue
More file actions
122 lines (100 loc) · 2.78 KB
/
vue
File metadata and controls
122 lines (100 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
description: Enforces best practices for Vue development, focusing on component architecture, template syntax, and reactivity patterns. Provides comprehensive guidelines for writing clean, efficient, and maintainable Vue applications.
globs: ["**/*.vue", "**/*.js", "**/*.ts"]
---
## Vue-Specific Rules
Cursor rules in Vue provide intelligent navigation and manipulation capabilities designed specifically for Vue development. These rules help you work more efficiently with Vue components, directives, and template syntax.
### Component Navigation
- Navigate between component definitions and their usages
- Jump to lifecycle hook declarations and methods
- Move between template sections and script blocks
- Quick access to component props and computed properties
### Smart Selection
- Select template blocks and expressions
- Expand selection to include directives and their arguments
- Smart component prop and event selection
- Select complete component definitions including all blocks
### Code Manipulation
- Quick component creation and refactoring
- Automated directive handling and optimization
- Computed property and watcher management
- Template structure manipulation
## Best Practices
- Use template-aware navigation for better code organization
- Leverage directive-specific cursor movements
- Utilize component-aware selection patterns
- Follow Vue component lifecycle patterns
- Implement proper Composition API patterns when applicable
## Examples
```vue
<!-- Navigate between component sections -->
<template>
<div class="user-profile">
<h1>{{ user.name }}</h1>
<UserStats
:stats="userStats"
@update="handleUpdate"
/>
</div>
</template>
<script>
export default {
name: 'UserProfile',
props: {
user: {
type: Object,
required: true
}
},
data() {
return {
userStats: null
}
},
computed: {
fullName() {
return `${this.user.firstName} ${this.user.lastName}`
}
},
methods: {
handleUpdate(stats) {
this.userStats = stats
}
}
}
</script>
<!-- Composition API Example -->
<script setup>
import { ref, computed, onMounted } from 'vue'
const props = defineProps({
userId: {
type: String,
required: true
}
})
const user = ref(null)
const userStats = ref(null)
const fullName = computed(() => {
if (!user.value) return ''
return `${user.value.firstName} ${user.value.lastName}`
})
onMounted(async () => {
user.value = await fetchUser(props.userId)
})
function handleUpdate(stats) {
userStats.value = stats
}
</script>
``
## Configuration
Customize Vue-specific cursor rules in your settings:
```json
{
"vue.cursorRules": {
"componentNavigation": true,
"smartSelection": true,
"templateHandling": true,
"compositionApiSupport": true,
"directiveAwareness": true
}
}