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>

运行结果:

相关推荐
贾公子1 小时前
AI 内容检测 API 接入实战——异步任务、幂等键与轮询的正确写法
vue.js
inksci1 小时前
发布Ai生成的html markdown 推荐
前端·javascript·html
在西安放羊的牛油果1 小时前
WebP 图片优化方案详解
运维·前端·架构
coding漫漫长路1 小时前
签名PDF一压就失效,接压缩需求前先查这5件事
前端
Lank_M1 小时前
PDF签完名还能改什么?会签能过,压缩不行
前端
补码缩写2 小时前
压缩前查PDF签名,字节搜索会漏掉对象流
前端
星光不问赶路人2 小时前
Vue 项目类型检查:深入理解 vue-tsc --build
前端·vue.js
修炼的dance2 小时前
压完的PDF验签不报错,是因为签名被删了
前端
ModStart2 小时前
想玩 AI 翻唱?SeedVC 模型 + AIGCPanel 上手
前端