• vue指令(代码部分二)


    1. <template>
    2. <view>
    3. <view v-on:click="onClick">{{title}}view>
    4. <button @click="clickNum">数值:{{num}}button>
    5. <view class="box" :style="{background:bgcolor}" @click="clickBg">
    6. {{random}}
    7. view>
    8. <view class="block" :class ="{myactive:state}" @click="clickBlock">view>
    9. br>
    10. <view class="block" :class ="state ? 'myactive' : '' ">view>
    11. 点谁高亮显示
    12. <view class="nav">
    13. <view class="item" :class="navIndex==index ? 'active':'' " v-for="(item,index) in navArr" :key="item.id" @click="
    14. clickNav(index)">{{item.title}}view>
    15. view>
    16. view>
    17. template>
    18. <script>
    19. export default {
    20. data() {
    21. return {
    22. title:"uniapp",
    23. num:1,
    24. bgcolor:"red",
    25. random:0,
    26. state:false,
    27. navArr:[
    28. {id:1,title:"首页"},
    29. {id:2,title:"介绍"},
    30. {id:3,title:"教程"},
    31. {id:4,title:"组件"}
    32. ],
    33. navIndex:0
    34. };
    35. },
    36. methods:{
    37. onClick:function(){
    38. this.title="点击事件修改名字"
    39. },
    40. clickNum(){
    41. this.num++
    42. },
    43. clickBg(){
    44. // 随机变
    45. let color="#"+String(Math.random()).substr(3,6)
    46. this.random =Math.ceil(Math.random(0,100)*100)
    47. console.log(color)
    48. this.bgcolor=color
    49. },
    50. clickBlock(){
    51. this.state=!this.state
    52. },
    53. clickNav(e){
    54. this.navIndex=e
    55. }
    56. }
    57. }
    58. script>
    59. <style lang="scss">
    60. .box{
    61. width: 200rpx;
    62. height: 200rpx;
    63. }
    64. .block{
    65. width: 300rpx;
    66. height: 300rpx;
    67. background:blue ;
    68. }
    69. .myactive{
    70. width: 400rpx;
    71. background:pink;
    72. border-radius: 20rpx;
    73. }
    74. .nav{
    75. display: flex;
    76. justify-content:space-around;
    77. align-items: center;
    78. .item{
    79. flex: 1;
    80. line-height: 90rpx;
    81. background: #ccc;
    82. text-align: center;
    83. &.active{
    84. background: #1aa034;
    85. color: #fff;
    86. }
    87. }
    88. }
    89. style>

  • 相关阅读:
    qt使用mysql数据库
    SqlServer 数据库占用磁盘空间过大的解决方式
    Linux命令学习—Apache 服务器(上)
    零数科技向海南省委书记汇报数字金融创新
    QT QMdiArea控件 使用详解
    制作一个简单HTML电影网页设计(HTML+CSS)
    测试开发工程必备技能之一:Mock的使用
    scipy实现单因素方差分析
    Mysql行级锁
    Axure RP9 引入eCharts图表
  • 原文地址:https://blog.csdn.net/qq_44114187/article/details/133248481