摘要: 在文件utils里配置 const baseSize = 12 //设置rem函数 function setRem() { //页面宽度相对于设计图宽的缩放比例,根据需要修改 1920(设计稿宽度) const scale = document.documentElement.clientWidth 阅读全文
posted @ 2024-11-03 15:30 light丶 阅读(22) 评论(0) 推荐(0)
摘要: 命令: npx create-react-app 项目名称 1。npx:node.js的工具命令 查找并执行后续的命令包 2。create-react-app 核心包(固定写法),用于创建react项目 3。项目名称 react的项目名称(自定义) 阅读全文
posted @ 2024-06-29 13:14 light丶 阅读(8) 评论(0) 推荐(0)
摘要: //格式:defineEmits<{(e:事件名,val:数据类型):void}>() const emit = defineEmits<{ (e: 'get-msg', val: string): void, (e: 'say-hello', num: number): void }>() con 阅读全文
posted @ 2024-06-19 21:02 light丶 阅读(73) 评论(0) 推荐(0)
摘要: //这是没有用ts语法接收的props参数 defineProps({ color: String, size: { type: String, required: false, default: 'middle' }, }) //TS语法 //格式:withDefaults(defineProps 阅读全文
posted @ 2024-06-19 21:01 light丶 阅读(454) 评论(0) 推荐(0)
摘要: //语法结构:computed<返回值的类型>() 列子 //定义数据 const cuont = ref(0) type Item = { id: string name: string price: number } const list = ref<Item[]>([{ id: '1001', 阅读全文
posted @ 2024-06-19 20:53 light丶 阅读(345) 评论(0) 推荐(0)
摘要: html <div ref="divRef"> </div> <button @click="sethtml"></button> js //非空断言 :我们比ts更加清楚数据不是空值 const divRef = ref<HTMLDivElement | null>(null) const set 阅读全文
posted @ 2024-06-19 20:49 light丶 阅读(60) 评论(0) 推荐(0)
摘要: html <input type="text" @change="changeInput"> <p @click="showInfo(33)">点击输出33</p> <button @click="logInfo">点击</button> js //给形参定义类型event const change 阅读全文
posted @ 2024-06-19 20:45 light丶 阅读(38) 评论(0) 推荐(0)
摘要: 子组件 <script setup lang="ts"> import { ref, defineExpose } from 'vue'; const num = ref<number>(10) defineExpose({ num,//把值暴露出去,父级可以通过ref获取 }) </script> 阅读全文
posted @ 2024-06-19 20:37 light丶 阅读(79) 评论(0) 推荐(0)
摘要: 1 使用默认类型 const person = reactive({ name: 'zs', age: 20 }) console.log(person.name); 2 使用泛型 type GoodType = { name: string id: number price: number pic 阅读全文
posted @ 2024-06-19 20:24 light丶 阅读(93) 评论(0) 推荐(0)
摘要: 1使用默认类型 const str = ref("") str.value = 'tom 2 //使用泛型 const num = ref<number>() num.value = 20 type GoodType = { id: string name: string price: number 阅读全文
posted @ 2024-06-19 20:19 light丶 阅读(143) 评论(0) 推荐(0)