【建站服务】专业网站建设-网站设计-网站制作与网站开发-高端品牌企业宣传策划-江阴上往建站-域名申请
作者: 风兰 . 阅读量: 8 . 发表时间:2022-09-21 02:21:18
上往建站提供服务器空间服务商,百度快照排名,网站托管,百度推广运营,致力于设计外包服务与源代码定制开发,360推广,搜狗推广,增加网站的能见度及访问量提升网络营销的效果,主营:网站公司,百度推广公司电话,官网搭建服务,网站服务企业排名,服务器空间,英文域名等业务,专业团队服务,效果好。
专业网站建设-网站设计-网站制作与网站开发-高端品牌企业宣传策划-江阴上往建站

专业网站建设-网站设计-网站制作与网站开发-高端品牌企业宣传策划-江阴上往建站
上往建站提供搭建网站,域名注册,官网备案服务,网店详情页设计,企业网店,专业网络店铺管理运营全托管公司咨询电话,服务器空间,微信公众号托管,网页美工排版,致力于域名申请,竞价托管,软文推广,全网营销,提供标准级专业技术保障,了却后顾之忧,主营:虚拟主机,网站推广,百度竞价托管,网站建设,上网建站推广服务,网络公司有哪些等业务,专业团队服务,效果好。
服务热线:400-111-6878 手机微信同号:18118153152(各城市商务人员可上门服务)
关键词:网站建设,企业网站,网站制作,网页设计,高端网站建设,企业网站制作,网页制作,制作网站,网站设计,高端网页设计,高端网站设计,做网站,自适应网站



复楼上,加一个 watch 方法,objectStyle 的方式也能实现动态变化。
<div id="app"> <div v-bind:style="{color: 'red', fontSize: size + 'px'}">可以动态调节</div> <div v-bind:style="computedStyle">可以动态调节</div> <div v-bind:style="objectStyle"> 可以动态调节</div> <div v-bind:style="methodStyle()"> 可以动态调节</div> {{size}} <button @click="++size">+</button> <button @click="--size">-</button></div><script>var app = new Vue({ el: '#app', data: { size: 20, objectStyle: { color: 'green', fontSize: 20 + 'px' //this.size为undefined } }, methods:{ methodStyle: function(){ return {color: 'green', fontSize: this.size + 'px'} //失效,颜色也不会改变 } }, computed: { computedStyle: function(){ return {color: 'red' , fontSize: this.size + 'px'} } }, watch: { size: function(){ this.objectStyle.fontSize = this.size + 'px' } }})</script>尝试一下 »
zss
zzu***js@qq.com
初学者
126***6357@qq.com
样式操作整理。基本涵盖了全部
var myvue = new Vue({ el:'#mydiv', data:{ gettext: '', getclass1:true, getclass2:false, getp_style:true, // 这里的key是类名,value是boolean值。下面的vue+class的value才是类名,key是自定义的类的实例化对象。注意区分 styleobj:{ class1: true, class2: true, 'p-style': false // 这里也需要将带有连字符的样式用引号括起来 }, getdiv_style:{ // 定义样式调用条件 number1: true, number2: false }, // 下面几个其实可以理解为 伪类实例化 vueclass1: 'class1', vueclass2: 'class2', vuedivstyle: 'div-style', vuepstyle: 'p-style', // 动态改变字体大小 size: 15, fontstyle:{ // 绑定样式对象 fontSize: 25+'px', fontWeight: 'bold' }, colors: ['red','blue','cyan','pink','orange','yellow','black','white','purple'], // 动态改变颜色需要的颜色数组 colorstyle: { color: 'red', backgroundColor : 'blue', borderRadius: '20px' }, sizestyle:{ width: '300px', height: '100px' }, radiussize: 10 }, watch:{ size:function(){ this.fontstyle.fontSize = this.size+'px' }, gettext:function(str){ // 适用于只要填入内容就改变样式 str ? this.getdiv_style.number1 = false : this.getdiv_style.number1 = true } }, methods:{ changecolor:function(){ // 改变颜色 this.colorstyle.backgroundColor = this.colors[Math.floor(Math.random()*this.colors.length)] this.colorstyle.color = this.colors[Math.floor(Math.random()*this.colors.length)] }, changesize:function(){ // 改变尺寸 this.sizestyle.width = parseInt(this.sizestyle.width)+50+'px' this.sizestyle.height = parseInt(this.sizestyle.height)+20+'px' } }, computed:{ judegeuse:function(){ // 判断是否使用某个/些类 return { class1: false, class3: true, 'div-style': this.getdiv_style.number1&&!this.getdiv_style.number2 // 这里也需要将带有连字符的样式用引号括起来 } } }})