frontend-vue-development
41
总安装量
41
周安装量
#5153
全站排名
安装命令
npx skills add https://github.com/tencentblueking/bk-ci --skill frontend-vue-development
Agent 安装分布
claude-code
26
opencode
22
gemini-cli
21
cursor
18
antigravity
15
Skill 文档
å端 Vue å¼å
Quick Reference
ææ¯æ ï¼Vue 2.7 + Vuex 3.6 + Vue Router 3.6 + bk-magic-vue 2.5
æä»¶å½åï¼kebab-case.vueï¼å¦ group-table.vueï¼
缩è¿ï¼4 ç©ºæ ¼ | æ åå· | æ æå°¾éå· | HTML åå¼å·
API è°ç¨ï¼vue.$ajax.get/post/put/delete
æç®ç¤ºä¾
<template>
<div class="pipeline-list">
<bk-table :data="pipelines" v-loading="isLoading">
<bk-table-column prop="name" label="åç§°"></bk-table-column>
</bk-table>
</div>
</template>
<script>
export default {
data() {
return {
pipelines: [],
isLoading: false
}
},
created() {
this.fetchPipelines()
},
methods: {
async fetchPipelines() {
this.isLoading = true
try {
const res = await this.$ajax.get('/api/user/pipelines')
this.pipelines = res.data || []
} finally {
this.isLoading = false
}
}
}
}
</script>
<style lang="scss" scoped>
.pipeline-list {
padding: 20px;
}
</style>
When to Use
- å¼å Vue ç»ä»¶
- 管ç Vuex ç¶æ
- è°ç¨å端 API
- å¤ç页é¢äº¤äº
When NOT to Use
- å端 API å¼å â 使ç¨
01-backend-microservice-development - æå»ºæº Agent â 使ç¨
05-go-agent-development
å端åºç¨ç»æ
src/frontend/
âââ devops-pipeline/ # æµæ°´çº¿åºç¨
âââ devops-atomstore/ # ç åååºåºç¨
âââ devops-manage/ # 管çåºç¨
âââ bk-pipeline/ # æµæ°´çº¿ç»ä»¶åº
âââ bk-permission/ # æéç»ä»¶åº
ESLint æ ¸å¿è§å
{
'indent': ['error', 4], // 4 ç©ºæ ¼ç¼©è¿
'semi': ['error', 'never'], // ç¦ç¨åå·
'comma-dangle': ['error', 'never'], // ç¦ç¨æå°¾éå·
'vue/html-quotes': ['error', 'double'],// HTML åå¼å·
'vue/no-v-html': 'error', // ç¦æ¢ v-htmlï¼é² XSSï¼
'no-console': 'error' // ç¦æ¢ console
}
ç»ä»¶é项顺åº
export default {
components: { }, // 1. ç»ä»¶æ³¨å
mixins: [ ], // 2. æ··å
¥
props: { }, // 3. Props
data() { }, // 4. ååºå¼æ°æ®
computed: { }, // 5. 计ç®å±æ§
watch: { }, // 6. 侦å¬å¨
created() { }, // 7. çå½å¨æé©å
mounted() { },
methods: { } // 8. æ¹æ³
}
Props å®ä¹
props: {
resourceType: {
type: String,
default: ''
},
options: {
type: Array,
default: () => [] // 对象/æ°ç»ä½¿ç¨å·¥å彿°
}
}
API è°ç¨æ¨¡å¼
// GET
this.$ajax.get(`${prefix}/user/pipelines`)
// POST
this.$ajax.post(`${prefix}/user/pipelines`, data)
// é误å¤ç
this.$ajax.get(url)
.then(res => this.data = res.data)
.catch(err => {
if ([404, 403].includes(err.code)) {
this.errorCode = err.code
}
})
.finally(() => this.isLoading = false)
Vuex 使ç¨
// store/pipeline.js
export const actions = {
getPipelineList({ commit }, { projectId }) {
return vue.$ajax.get(`/api/user/projects/${projectId}/pipelines`)
}
}
// ç»ä»¶ä¸ä½¿ç¨
import { mapActions } from 'vuex'
methods: {
...mapActions('pipeline', ['getPipelineList']),
async fetchData() {
this.list = await this.getPipelineList({ projectId: this.projectId })
}
}
æ¹æ³å½å约å®
| ç±»å | å½åæ¨¡å¼ | ç¤ºä¾ |
|---|---|---|
| äºä»¶å¤ç | handle* |
handleClick() |
| åå§å | init* |
initData() |
| æ ¼å¼å | *Formatter |
statusFormatter() |
Checklist
å¼åç»ä»¶å确认ï¼
- æä»¶å½åä½¿ç¨ kebab-case
- éµå¾ª ESLint è§åï¼4 ç©ºæ ¼ãæ åå·ï¼
- Props 使ç¨å®æ´å®ä¹ï¼type + defaultï¼
- 对象/æ°ç» Props 使ç¨å·¥å彿°
- ç¦æ¢ä½¿ç¨ v-html
- ä½¿ç¨ scoped æ ·å¼