当前位置: 首页 > news >正文

vue3+ts v-model 深度学习

<template><div><h1>我是App.vue组件</h1><div>isShpw:{{ isShow }}</div><div>text:{{ text }}</div><div><button @click="isShow = !isShow">开关</button></div><hr /><vModeValue v-model:textVal.isBt="text" v-model="isShow"></vModeValue></div>
</template><script setup lang="ts">
import { ref, reactive } from "vue";
import vModeValue from "./components/v-model.vue";
const isShow = ref<boolean>(true);
const text = ref<string>("小满");
</script><style scoped></style>

v-model.vue:

<template><div class="model" v-if="modelValue"><div class="close"><button @click="close">关闭</button></div><h3>我是v-model子组件 dialog</h3><div>内容:<input @input="change" type="text" :value="textVal" /></div></div>
</template><script setup lang="ts">
import { ref, reactive } from "vue";
const props = defineProps<{modelValue: boolean;textVal: string;textValModifiers?: {isBt: boolean;};
}>();
const emit = defineEmits(["update:modelValue", "update:textVal"]);const close = () => {emit("update:modelValue", false);
};
const change = (e: Event) => {const target = e.target as HTMLInputElement;emit("update:textVal",props?.textValModifiers?.isBt ? target.value + "变态" : target.value);
};
</script><style>
.model {width: 500px;border: 5px solid #ccc;padding: 10px;
}
.close {display: flex;justify-content: flex-end;
}
</style>

在这里插入图片描述

http://www.lryc.cn/news/248606.html

相关文章:

  • 网络通信概述
  • <avue-crud/>,二级表头,children下字典项的dicUrl失效问题
  • FastApi接收不到Apifox发送的from-data字符串_解决方法
  • Python高级数据结构——堆(Heap)
  • linux 讨论题合集(个人复习)
  • 浅析SD-WAN技术如何加强企业网络安全
  • 测试相关-面试高频
  • 基于Java web的多功能游戏大厅系统的开发与实现
  • 【MySQL工具】my2sql-快速解析binlog
  • vueRouter常用属性
  • Qt5.15.2的镜像网址
  • Python隐藏特性:字符串驻留、常量折叠
  • 2-Python与设计模式--工厂类相关模式
  • PGP 遇上比特币
  • 项目demo —— GPT 聊天机器人
  • Airtest进阶使用篇!提高脚本稳定性 + 批量运行脚本!
  • 数据库系统概述之数据库优化
  • 【error:Custom elements in iteration require ‘v-bind:key‘ directives】元素绑定:key
  • TA-Lib学习研究笔记(二)——Overlap Studies下
  • 三.排序与分页
  • 第一个php扩展开发的demo
  • A stop job is running for Session c1 of user root (25s 1min 30s)问题
  • C语言进阶之笔试题详解(2)
  • 【开源】基于Vue和SpringBoot的独居老人物资配送系统
  • Linux常用命令----cp 命令
  • 前端:HTML鼠标样式及其对应的CSS属性值
  • Linux 命令chgrp chown chmod
  • 网络篇---第七篇
  • Webshell混淆免杀的一些思路
  • MacBook macOs安装RabbitMQ【超详细图解】