当前位置: 首页> 财经> 创投人物 > 【vue-3】动态属性绑定v-bind

【vue-3】动态属性绑定v-bind

时间:2025/7/10 7:09:43来源:https://blog.csdn.net/WXG1011/article/details/139115137 浏览次数:0次

1、文本动态绑定:

<input type="text" v-bind:value="web.url">

简写:

<input type="text" :value="web.url">

 2、文字样式动态绑定

<b :class="{textColor:web.fontStatus}">vue学习</b>

完整示例代码:

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><!-- <script src="vue.global.js"></script> --><style>.textColor{color:blue}</style>
</head>
<body><div id="app"><h1>value="www.vue.com"</h1>   <input type="text" value="vue.com"> <h1>v-bind:value="web.url"</h1>   <input type="text" v-bind:value="web.url"> <h1>:value="web.url"</h1>   <input type="text" :value="web.url"> <h1>src="test.jpg"</h1>   <img src="test.jpg"><h1>:src="web.img"</h1>   <img :src="web.img"><h1>class="textColor"</h1><b class="textColor">vue学习</b><h1>:class="{textColor:web.fontStatus}"</h1><b :class="{textColor:web.fontStatus}">vue学习</b></div><script type="module">import {createApp, reactive} from './vue.esm-browser.js'// const {createApp, reactive} = VuecreateApp({// setup选项,用于设置响应式数据和方法等setup(){ const web = reactive({url:"www.vue.com",img:"test.jpg",fontStatus:true})return{web     }}}).mount("#app")// mount为挂载</script>
</body>
</html>

关键字:【vue-3】动态属性绑定v-bind

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: