【Vue】input文本框通过methods和computed动态绑定数值
Vue 通过 动态 绑定 input 数值 文本框 methods
2023-09-11 14:14:57 时间
computed计算属性说明:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<!-- <SCRIPT type="text/javascript" src="vue.js"></SCRIPT> -->
<script src="vue.js"></script>
<body>
<div id="root">
姓:<input type="text" v-model:value="sex"><br><br>
名:<input type="text" v-model:value="name">
<h4>您输入的完整姓名是:</h4>
<h4>1.正常写法:{{sex}}-{{name}}</h5>
<h4>2.methods事件写法:{{fullName()}}</h5>
<h3>3.computed计算写法:{{fullName_run}}</h5>
<h3>4.computed计算简单类函数写法:{{fullName_easy}}</h5>
</div>
</body>
<script type="text/javascript">
var root = new Vue({
// var root=new Vue({
el: '#root',
data: {
sex: "张",
name: "三"
},
methods: {
fullName() {
return this.sex + "-" + this.name;
}
},
computed: {
fullName_run: {
get() {
return this.sex + "_" + this.name;
}
},
fullName_easy() {
return this.sex + "_" + this.name;
}
},
})
</script>
</html>
相关文章
- Vue笔记:vue项目引入bootstrap、elementUI、echarts
- vue :src 不显示的解决方案
- vue - 组件传值
- Vue - slot-scope="scope" 的意义
- [Vue @Component] Define Props on a Vue Class with vue-property-decorator
- Vue.js3: 页面打开前实现图片全部预加载(vue@3.2.33)
- 使用vue搭建应用一入门
- Vue 基础知识
- Vue.js3: 页面打开前实现图片全部预加载(vue@3.2.33)
- Vue入门教程:node安装vue命令行工具及启动项目
- SAP Spartacus 支持 Vue 吗?
- 使用 SAP Business Application Studio 开发 Vue 应用
- vue-router路由的安装、配置、具体用法和Vue-router学习笔记
- vue - 通过JS屏蔽自带右键菜单
- 计算机毕设项目 40个高质量SSM+VUE毕设项目分享【源码+论文】(八)
- 解决springboot+vue+mybatis中,将后台数据分页显示在前台,并且根据页码自动跳转对应页码信息
- vue-router路由实现页面的跳转
- Vue、Vuejs从入门到精通 | vue-router详解
- 213:vue+openlayers 通过WFS服务加载geoserver发布的geojson矢量数据
- Vue(五)计算属性、过滤器、axios、vue 生命周期
- Visual Studio Code 安装 Vue插件需求
- Vue学习笔记——vue-router