Skip to content

Commit

Permalink
feat: 添加ReDrawer demo
Browse files Browse the repository at this point in the history
  • Loading branch information
simple-hui committed Sep 3, 2024
1 parent 6bccf3a commit 99d67ed
Show file tree
Hide file tree
Showing 6 changed files with 582 additions and 1 deletion.
3 changes: 2 additions & 1 deletion locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ menus:
pureFive: "500"
pureComponents: Components
pureDialog: Dialog
pureDrawer: Drawer
pureMessage: Message Tips
pureVideo: Video
pureSegmented: Segmented
Expand Down Expand Up @@ -233,4 +234,4 @@ login:
purePassWordRuleReg: The password format should be any combination of 8-18 digits
purePassWordSureReg: Please enter confirm password
purePassWordDifferentReg: The two passwords do not match!
purePassWordUpdateReg: Password has been updated
purePassWordUpdateReg: Password has been updated
1 change: 1 addition & 0 deletions locales/zh-CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ menus:
pureFive: "500"
pureComponents: 组件
pureDialog: 函数式弹框
pureDrawer: 函数式抽屉
pureMessage: 消息提示
pureVideo: 视频
pureSegmented: 分段控制器
Expand Down
8 changes: 8 additions & 0 deletions src/router/modules/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export default {
title: $t("menus.pureDialog")
}
},
{
path: "/components/drawer",
name: "DrawerPage",
component: () => import("@/views/components/drawer/index.vue"),
meta: {
title: $t("menus.pureDrawer")
}
},
{
path: "/components/message",
name: "Message",
Expand Down
47 changes: 47 additions & 0 deletions src/views/components/drawer/form.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<script setup lang="ts">
import { ref } from "vue";
// 声明 props 类型
export interface FormProps {
formInline: {
user: string;
region: string;
};
}
// 声明 props 默认值
// 推荐阅读:https://cn.vuejs.org/guide/typescript/composition-api.html#typing-component-props
const props = withDefaults(defineProps<FormProps>(), {
formInline: () => ({ user: "", region: "" })
});
// vue 规定所有的 prop 都遵循着单向绑定原则,直接修改 prop 时,Vue 会抛出警告。此处的写法仅仅是为了消除警告。
// 因为对一个 reactive 对象执行 ref,返回 Ref 对象的 value 值仍为传入的 reactive 对象,
// 即 newFormInline === props.formInline 为 true,所以此处代码的实际效果,仍是直接修改 props.formInline。
// 但该写法仅适用于 props.formInline 是一个对象类型的情况,原始类型需抛出事件
// 推荐阅读:https://cn.vuejs.org/guide/components/props.html#one-way-data-flow
const newFormInline = ref(props.formInline);
</script>

<template>
<el-form :model="newFormInline">
<el-form-item label="姓名">
<el-input
v-model="newFormInline.user"
class="!w-[220px]"
placeholder="请输入姓名"
/>
</el-form-item>
<el-form-item label="城市">
<el-select
v-model="newFormInline.region"
class="!w-[220px]"
placeholder="请选择城市"
>
<el-option label="上海" value="上海" />
<el-option label="浙江" value="浙江" />
<el-option label="深圳" value="深圳" />
</el-select>
</el-form-item>
</el-form>
</template>
22 changes: 22 additions & 0 deletions src/views/components/drawer/formPrimitive.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script setup lang="ts">
import { useVModel } from "@vueuse/core";
// 声明 props 类型
export interface FormProps {
data: string;
}
// 声明 props 默认值
// 推荐阅读:https://cn.vuejs.org/guide/typescript/composition-api.html#typing-component-props
const props = withDefaults(defineProps<FormProps>(), {
data: () => ""
});
// 使用 vueuse 的双向绑定工具
const emit = defineEmits(["update:data"]);
const data = useVModel(props, "data", emit);
</script>

<template>
<el-input v-model="data" class="!w-[220px]" placeholder="请输入内容" />
</template>
Loading

0 comments on commit 99d67ed

Please sign in to comment.