作业
发布于 2 年前 作者 xieguiying 5073 次浏览 来自 分享

<view class='box'>

<view class='title'>滑动条和颜色</view>

<text>红色滑动条</text>

<slider data-color="rvalue='{{r}}'max='255block-color='redshow-value="truebindchanging='colorchanging'></slider>

<text>绿色滑动条</text>

<slider data-color="gvalue='{{g}}'max='255block-color='greenshow-value="truebindchanging='colorchanging'></slider>

<text>蓝色滑动条</text>

<slider data-color="bvalue='{{b}}'max='255block-color='blueshow-value="truebindchanging='colorchanging'></slider>

<text>透明度滑动条</text>

<slider data-color="avalue='{{a}}'max='1step='0.01block-color='purpleshow-value="truebindchanging='colorchanging'></slider>

<view class='colorareastyle='background-color: rgba({{r}},{{g}},{{b}},{{a}});'></view>

</view>

-----------------------------------------------------------------

Page({

  data:{

    r:50,

    g:100,

    b:150,

    a:1

  },

  colorchanging(e){

    let color=e.currentTarget.dataset.color

    let value=e.detail.value;

    console.log(color,value)

    this.setData({

      [color]:value

    })

  }

})

-----------------------------------------------------------------------------------

<view class='box'>

  <view class='title'>Swiper and Switch</view>

  <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" circular="{{circular}}" vertical="{{vertical}}" interval="{{interval}}" duration="{{duration}}">

    <block wx:for="{{background}}" wx:key="index">

      <swiper-item>

        <view class="{{item}}"></view>

      </swiper-item>

    </block>

  </swiper>

  <view class='waikuang'>

    <text class='myleft'>指示器</text>

    <switch checked='{{indicatorDots}}'bindchange="changeIndicatorDots"/>

  </view>

  <view class='waikuang'>

    <text class='myleft'>自动播放</text>

    <switch checked='{{autoplay}}' bindchange="changeAutopaly"/>

  </view>

  <view class='waikuang'>

    <text class='{{myleft}}'>衔接滑动</text>

    <switch checked='circularbindchange="changeCircular"/>

  </view>

  <view class='waikuang'>

    <text class='myleft'>竖向</text>

    <switch checked='{{vertical}}' bindchange="changeVertical"/>

  </view>

</view>

--------------------------------------------------------------------

Page({

  data:{

    background:['bc-red','bc-green','bc-blue'],

    indicatorDots:true,

    autoplay:false,

    circular:false,

    vertical:false,

    interval:false,

    duration:false,

  },

  changeIndicatorDots:function(e){

    this.setData({

      indicatorDots:!this.data.indicatorDots

    })

  },

  changeAutopaly:function(e){

    this.setData({

      autopaly:!this.data.autopaly

    })

  },

  changeCircular:function(e){

    this.setData({

      circular:!this.data.circular

    })

  }

  ,changeVertical:function(e){

    this.setData({

      vertical:!this.data.vertical

    })

  },

})

--------------------------------------------------------------------------------

<view class='box'>

  <view class='title'>修改字体样式和大小</view>

  <text style='font-weight:{{myBold}};font-style:{{myItalic}};text-decoration:{{myUnderline}};font-size:{{myFontSize}}'>上海大学</text>

  <checkbox-group bindchange='checkboxChange'>

    <checkbox value='isBold'>加粗</checkbox>

    <checkbox value='isItalic'>倾斜</checkbox>

    <checkbox value='isUnderline'>下划线</checkbox>

  </checkbox-group>

  <radio-group bindchange='radioChange'>

    <radio value='15px'>15px</radio>

    <radio value='25pxchecked='true'>25px</radio>

    <radio value='35px'>35px</radio>

  </radio-group>

</view>

============================================

Page({

  data:{

    myFontsize:'25px'

  },

  checkboxChange:function(e){

    var text=[];

    var mybold='';

    var myitalic='';

    var myunderline='';

    text=e.detail.value;

    for(var i=0;i<text.length;i++){

      if(text[i]=='isBold'){

        mybold='bold';

      }

      if(text[i]=='isItalic'){

        myitalic='italic';

      }

      if(text[i]=='isUnderline'){

        myunderline='underline';

      }

    }

    this.setData({

      myBold:mybold,

      myItalic:myitalic,

      myUnderline:myunderline,

    })

    console.log(text[0])

  },

  radioChange:function(e){

    this.setData({

      myFontSize:e.detail.value,

    })

    console.log(e.detail.value)

  }

})

<view class='box'>

<view class='title'>滑动条和颜色</view>

<text>红色滑动条</text>

<slider data-color="rvalue='{{r}}'max='255block-color='redshow-value="truebindchanging='colorchanging'></slider>

<text>绿色滑动条</text>

<slider data-color="gvalue='{{g}}'max='255block-color='greenshow-value="truebindchanging='colorchanging'></slider>

<text>蓝色滑动条</text>

<slider data-color="bvalue='{{b}}'max='255block-color='blueshow-value="truebindchanging='colorchanging'></slider>

<text>透明度滑动条</text>

<slider data-color="avalue='{{a}}'max='1step='0.01block-color='purpleshow-value="truebindchanging='colorchanging'></slider>

<view class='colorareastyle='background-color: rgba({{r}},{{g}},{{b}},{{a}});'></view>

</view>


Page({

  data:{

    r:50,

    g:100,

    b:150,

    a:1

  },

  colorchanging(e){

    let color=e.currentTarget.dataset.color

    let value=e.detail.value;

    console.log(color,value)

    this.setData({

      [color]:value

    })

  }

})


<view class='box'>

  <view class='title'>Swiper and Switch</view>

  <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" circular="{{circular}}" vertical="{{vertical}}" interval="{{interval}}" duration="{{duration}}">

    <block wx:for="{{background}}" wx:key="index">

      <swiper-item>

        <view class="{{item}}"></view>

      </swiper-item>

    </block>

  </swiper>

  <view class='waikuang'>

    <text class='myleft'>指示器</text>

    <switch checked='{{indicatorDots}}'bindchange="changeIndicatorDots"/>

  </view>

  <view class='waikuang'>

    <text class='myleft'>自动播放</text>

    <switch checked='{{autoplay}}' bindchange="changeAutopaly"/>

  </view>

  <view class='waikuang'>

    <text class='{{myleft}}'>衔接滑动</text>

    <switch checked='circularbindchange="changeCircular"/>

  </view>

  <view class='waikuang'>

    <text class='myleft'>竖向</text>

    <switch checked='{{vertical}}' bindchange="changeVertical"/>

  </view>

</view>


Page({

  data:{

    background:['bc-red','bc-green','bc-blue'],

    indicatorDots:true,

    autoplay:false,

    circular:false,

    vertical:false,

    interval:false,

    duration:false,

  },

  changeIndicatorDots:function(e){

    this.setData({

      indicatorDots:!this.data.indicatorDots

    })

  },

  changeAutopaly:function(e){

    this.setData({

      autopaly:!this.data.autopaly

    })

  },

  changeCircular:function(e){

    this.setData({

      circular:!this.data.circular

    })

  }

  ,changeVertical:function(e){

    this.setData({

      vertical:!this.data.vertical

    })

  },

})


<view class='box'>

  <view class='title'>修改字体样式和大小</view>

  <text style='font-weight:{{myBold}};font-style:{{myItalic}};text-decoration:{{myUnderline}};font-size:{{myFontSize}}'>上海大学</text>

  <checkbox-group bindchange='checkboxChange'>

    <checkbox value='isBold'>加粗</checkbox>

    <checkbox value='isItalic'>倾斜</checkbox>

    <checkbox value='isUnderline'>下划线</checkbox>

  </checkbox-group>

  <radio-group bindchange='radioChange'>

    <radio value='15px'>15px</radio>

    <radio value='25pxchecked='true'>25px</radio>

    <radio value='35px'>35px</radio>

  </radio-group>

</view>

============================================

Page({

  data:{

    myFontsize:'25px'

  },

  checkboxChange:function(e){

    var text=[];

    var mybold='';

    var myitalic='';

    var myunderline='';

    text=e.detail.value;

    for(var i=0;i<text.length;i++){

      if(text[i]=='isBold'){

        mybold='bold';

      }

      if(text[i]=='isItalic'){

        myitalic='italic';

      }

      if(text[i]=='isUnderline'){

        myunderline='underline';

      }

    }

    this.setData({

      myBold:mybold,

      myItalic:myitalic,

      myUnderline:myunderline,

    })

    console.log(text[0])

  },

  radioChange:function(e){

    this.setData({

      myFontSize:e.detail.value,

    })

    console.log(e.detail.value)

  }

})

回到顶部