vue属性绑定v-bind

属性绑定v-bind

双大括号不能在HTML attributes 中使用。想要响应式地绑定一个attribute,应该使用v-bind指令。

v-bind 指令指示Vue将元素id attribute 与组件的dyid属性保持一致。如果绑定值是null或者undefined,那么该attribute将会从渲染的元素上移除。

运行结果:

简写

因为v-bind:非常常用,可以将v-bind:简写为

动态绑定多个

bash 复制代码
<template>
<div v-bind="objectof">App</div>
</template>
<script>

export default{
    data(){
        return{
          objectof:{
            id:'appid',
            class:'appclass'
          }
        }
    }
}

</script>
<style scoped>
.appclass{
    color: red;
}
#appid{
    background-color: yellow;
}
</style>

运行结果:

相关推荐
问心无愧05137 小时前
ctf show web入门160 161
前端·笔记
李小白667 小时前
第四天-WEB服务器基本原理,IIS服务
运维·服务器·前端
humcomm8 小时前
AI编程时代新前端职位
前端·ai编程
好家伙VCC8 小时前
Web Components主题热切换方案揭秘
java·前端
甲维斯9 小时前
Kimi版超级玛丽效果“惊人”,配额不足5厘米!
前端·人工智能
hboot9 小时前
AI工程师第一课 - Python
前端·后端·python
凉菜凉凉9 小时前
AI时代,被抛弃的前端
前端·ai
console.log('npc')9 小时前
AI前端工程与生成式UI学习路线
前端·人工智能·ui
huangdong_9 小时前
淘宝商品SKU图自动分类技术深度解析:从DOM解析到智能归档
开发语言·javascript·ecmascript
梦曦i9 小时前
uni-router v1.1.1发布:守卫超时保护+路由监听
前端·uni-app