feat: 调整项目结构
This commit is contained in:
44
src/components/CheckBox/index.vue
Normal file
44
src/components/CheckBox/index.vue
Normal file
@@ -0,0 +1,44 @@
|
||||
<template>
|
||||
<view class="checkbox-wrapper" @click.stop="onChange">
|
||||
<uni-icons
|
||||
class="checkbox-icon"
|
||||
:type="isChecked"
|
||||
:checked="isChecked"
|
||||
:color="iconColor"
|
||||
size="24"
|
||||
/>
|
||||
<slot></slot>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, defineEmits } from "vue";
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(["update:modelValue"]);
|
||||
|
||||
// 计算属性,确定当前是否选中
|
||||
const isChecked = computed(() => {
|
||||
return props.modelValue ? "checkbox-filled" : "circle";
|
||||
});
|
||||
|
||||
// 计算图标颜色
|
||||
const iconColor = computed(() => {
|
||||
return props.modelValue ? "#1890FF" : "#00A6FF";
|
||||
});
|
||||
|
||||
// 切换选中状态
|
||||
const onChange = () => {
|
||||
emit("update:modelValue", !props.modelValue);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@use "./styles/index.scss";
|
||||
</style>
|
||||
12
src/components/CheckBox/propmt.md
Normal file
12
src/components/CheckBox/propmt.md
Normal file
@@ -0,0 +1,12 @@
|
||||
## 复选框组件
|
||||
|
||||
## 提示词:
|
||||
|
||||
使用 uniapp + vue3 组合式 api 开发微信小程序,要求如下:
|
||||
1、按照提供的图片高度还原交互设计
|
||||
2、要求布局样式结构简洁明了,class 命名请按照模块名称来命名,例如:.checkbox-wrapper
|
||||
3、可以使用 uniapp 内置的组件
|
||||
|
||||
## 备注
|
||||
|
||||
仅供学习、交流使用,请勿用于商业用途。
|
||||
8
src/components/CheckBox/styles/index.scss
Normal file
8
src/components/CheckBox/styles/index.scss
Normal file
@@ -0,0 +1,8 @@
|
||||
.checkbox-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.checkbox-icon {
|
||||
margin-right: 6px;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user