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>

运行结果:

相关推荐
fthux4 小时前
RenoPit 能为普通业主做什么?看懂图纸、审查合同,提前发现装修坑
javascript·人工智能·ai·开源·github·chrome扩展·open source·edge扩展·firefox扩展
仿生狮子5 小时前
✂️ Nuxt 最简单的字体裁剪工具:Fontize
javascript·vue.js·nuxt.js
石小石Orz8 小时前
我发现了开发者AI产品营收的新方向
前端·虚拟现实
老马识途2.08 小时前
关于跨域问题的总结
java·前端
魔力女仆8 小时前
分享一个 JS 鼠标跟随贪吃蛇背景库
开发语言·javascript·计算机外设
别惊醒渔人10 小时前
Vue3 Diff 优化:最长递增子序列 LIS
前端·javascript·vue.js
颜酱10 小时前
07 | 把字段与指标同步到 Qdrant(生成阶段)
前端·人工智能·后端
用户0595401744610 小时前
把AI长期记忆测试从手动验证换成pytest,2天揪出11个隐藏Bug
前端·css
Larcher10 小时前
从“加载模型”界面到端侧推理:拆解一个 React + WebGPU 大模型 Demo
javascript·后端
Larcher11 小时前
从状态快照到惰性初始化:读懂 React useState 的三个关键场景
javascript·人工智能·后端