Skip to content

Commit 5b016fe

Browse files
committed
添加代码片段
1 parent db85ae7 commit 5b016fe

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

.vscode/crud.code-snippets

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"cl-crud": {
3-
"prefix": "cl-crud",
3+
"prefix": "cl-crud-ts",
44
"body": [
55
"<template>",
6-
" <cl-crud ref=\"crud\" @load=\"onLoad\">",
6+
" <cl-crud :ref=\"setRefs('crud')\" @load=\"onLoad\">",
77
" <el-row type=\"flex\" align=\"middle\">",
88
" <!-- 刷新按钮 -->",
99
" <cl-refresh-btn />",
@@ -18,7 +18,7 @@
1818
"",
1919
" <el-row>",
2020
" <!-- 数据表格 -->",
21-
" <cl-table v-bind=\"table\"></cl-table>",
21+
" <cl-table :ref=\"setRefs('table')\" v-bind=\"table\"></cl-table>",
2222
" </el-row>",
2323
"",
2424
" <el-row type=\"flex\">",
@@ -28,31 +28,47 @@
2828
" </el-row>",
2929
"",
3030
" <!-- 新增、编辑 -->",
31-
" <cl-upsert ref=\"upsert\" v-bind=\"upsert\"></cl-upsert>",
31+
" <cl-upsert :ref=\"setRefs('upsert')\" v-bind=\"upsert\"></cl-upsert>",
3232
" </cl-crud>",
3333
"</template>",
3434
"",
35-
"<script>",
36-
"export default {",
37-
" data() {",
38-
" return {",
39-
" // 新增、编辑配置",
40-
" upsert: {",
41-
" items: []",
42-
" },",
43-
" // 表格配置",
44-
" table: {",
45-
" columns: []",
46-
" }",
47-
" };",
48-
" },",
49-
" methods: {",
50-
" onLoad({ ctx, app }) {",
51-
" ctx.service(${1}).done();",
35+
"<script lang=\"ts\">",
36+
"import { defineComponent, inject, reactive } from \"vue\";",
37+
"import { CrudLoad, Upsert, Table } from \"@/crud/types\";",
38+
"import { useRefs } from \"@/core\";",
39+
"",
40+
"export default defineComponent({",
41+
" setup() {",
42+
" const { refs, setRefs } = useRefs();",
43+
" // 请求服务",
44+
" const service = inject<any>(\"service\");",
45+
"",
46+
" // 新增、编辑配置",
47+
" const upsert = reactive<Upsert>({",
48+
" items: []",
49+
" });",
50+
"",
51+
" // 表格配置",
52+
" const table = reactive<Table>({",
53+
" columns: []",
54+
" });",
55+
"",
56+
" // crud 加载",
57+
" function onLoad({ ctx, app }: CrudLoad) {",
58+
" // 绑定 service",
59+
" ctx.service(service.xx).done();",
5260
" app.refresh();",
5361
" }",
62+
"",
63+
" return {",
64+
" refs,",
65+
" setRefs,",
66+
" upsert,",
67+
" table,",
68+
" onLoad",
69+
" };",
5470
" }",
55-
"};",
71+
"});",
5672
"</script>",
5773
""
5874
],

0 commit comments

Comments
 (0)