Vue.js框架--v-bind绑定title ,src, html,text,class,style(三)

主要操作技能:

    v-bind:title  鼠标移上的显示

    v-bind:src  绑定图片路径

    v-bind:html 绑定HTML文本和标签

    v-bind:text 绑定文本

    v-bind:class 绑定类样式

    v-bind:style  动态绑定样式

编写代码

<template>
  <div id="app">
  	
  	<!--鼠标移上 v-bind:title -->
    <div v-bind:title="title">
                 鼠标移上去看看哦!
    </div><br />
    
     <!--图片1 v-bind:src-->
     <div>
     	 <img v-bind:src="url" />
     </div><br />
     
      <!--图片2 属性:src-->
     <img :src="url" /><br /><br />
     
      <!--
                  绑定HTML标签输出
      -->
      <div v-html="htmls"></div><br />
      
      <!-- 绑定数据另一个方法-->
       
      {{msg}}  等同于&nbsp;  <span v-text="msg"></span><br />
      
      <!--v-bind:class类样式-->
      <div v-bind:class="{'my':flag}">this is test v-bind class</div><br />
      
      
      <div v-bind:class="{'my':flag,'your':!flag}">this is test v-bind class</div><br />

      <!--直接用属性:class类样式-->
      <div :class="{'my':!flag}">this is test v-bind class</div><br /><br />
     
      <!-- 循环数据-->
      <ul>
      	<li v-for="it in list">
      		{{it}}
      	</li>
      </ul>
      
      <br />
      
      <!-- 循环数据使用样式-->
      <ul>
      	<li v-for="(it,key) in list" :class="{'my':key==0,'your':key==1}">
      		{{key}}==>{{it}}
      	</li>
      </ul><br />
      
   
       <!--v-bind:style style使用动态改变宽样式 ,必须加px哦!-->
       <div class="box" v-bind:style="{width:boxWdith+'px'}">
       	 盒子
       </div>
      
      
      
      
      
     
     
  </div>
</template>

<script>
export default {
  name: 'app',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      title:'我是一个标题哦!',
//    url:'https://goss4.vcg.com/creative/vcg/material/400/VCG211161017213.jpg',
      url:'https://goss2.vcg.com/creative/vcg/material/400/VCG211161017209.jpg',
      htmls:'<h3>helloworld</h3>',
      flag:false,
      list:['aaa','bbb','ccc','ddd'],
      boxWdith:400 //宽度
      
    }
  }
}
</script>

<style lang="scss">
   .my{
   	 color:darkgoldenrod;
   	 font-weight: bolder;
   }
   
   .your{
   	color:blue;
   	font-size: 15px;
   }
   
   .box{
   	width: 100px;
   	height: 100px;
   	background: coral;
   }
</style>

效果:

 

 

 

 

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值