vue再读27v-model语法糖原理

简介: vue再读27v-model语法糖原理
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .active {
        color: red;
    }
</style>
<body>
    <!-- 数据渲染界面 -->
    <!-- 绑定表单元素 双向数据绑定 -->
    <div id="abc">
        {{msg}}
        <input type="text" v-model="msg">
        <input :value="msg" @input="msg=$event.target.value">
        <input :value="msg" @input="fn($event)">
    </div>
    <script src="./js/vue.js"></script>
    <script>
        var vm = new Vue({
            //v-on里面的methods方法
            el: '#abc',
            //模板ajax返回的数据
            data: {
                msg: "geyao"
            },
            methods: {
                fn(e) {
                    console.log(e.targrt.value);
                    this.msg = e.targrt.value;
                }
            }
        })
    </script>
    <!-- 列表渲染 -->
    <!-- 1渲染数组 -->
    <!-- 2c处理无数据的时候 -->
</body>
</html>

image.png

相关文章
|
2天前
|
JavaScript
vue 函数化组件
vue 函数化组件
|
2天前
|
JavaScript API
vue学习(13)监视属性
vue学习(13)监视属性
13 2
|
2天前
|
JavaScript 前端开发
vue学习(15)watch和computed
vue学习(15)watch和computed
9 1
|
2天前
|
JavaScript
vue学习(14)深度监视
vue学习(14)深度监视
11 0
|
4月前
|
JavaScript API
【vue实战项目】通用管理系统:api封装、404页
【vue实战项目】通用管理系统:api封装、404页
65 3
|
4月前
|
人工智能 JavaScript 前端开发
毕设项目-基于Springboot和Vue实现蛋糕商城系统(三)
毕设项目-基于Springboot和Vue实现蛋糕商城系统
|
4月前
|
JavaScript Java 关系型数据库
毕设项目-基于Springboot和Vue实现蛋糕商城系统(一)
毕设项目-基于Springboot和Vue实现蛋糕商城系统
146 0
|
4月前
|
JavaScript 前端开发 API
Vue3+Vite+TypeScript常用项目模块详解
现在无论gitee还是github,越来越多的前端开源项目采用Vue3+Vite+TypeScript+Pinia+Elementplus+axios+Sass(css预编译语言等),其中还有各种项目配置比如eslint 校验代码工具配置等等,而我们想要进行前端项目的二次开发,就必须了解会使用这些东西,所以作者写了这篇文章进行简单的介绍。
125 0
Vue3+Vite+TypeScript常用项目模块详解
|
4月前
|
设计模式 JavaScript
探索 Vue Mixin 的世界:如何轻松复用代码并提高项目性能(上)
探索 Vue Mixin 的世界:如何轻松复用代码并提高项目性能(上)
探索 Vue Mixin 的世界:如何轻松复用代码并提高项目性能(上)
|
4月前
|
前端开发 JavaScript Java
毕业设计|基于SpringBoot+Vue的科研课题项目管理系统
毕业设计|基于SpringBoot+Vue的科研课题项目管理系统
167 1