# 2.2 首页背景(Background)

根据规范色,延展了首页的背景,可根据主色选择对应的渐变背景色。

# 实例

# 基础用法

<template>
  <div class="wrapper">
    <dof-minibar
      title="设备"
      :background-color="startColor"
      text-color="#ffffff"
      :left-button="leftButton"
      @dofMinibarLeftButtonClicked="back"
      right-text=""
    ></dof-minibar>
    <scroller class="scroller" show-scrollbar="false" :offset-accuracy="20" :style="{ 'background-color': startColor }">
      <dof-gradient :width="width" :height="height" :startColor="startColor" :endColor="endColor"></dof-gradient>
      <div class="board-box">
        <dof-board>
          <dof-card class="m-b-10">
            <div class="placeholder"></div>
          </dof-card>
          <dof-row class="m-b-10">
            <dof-col>
              <dof-card>
                <div class="placeholder"></div>
              </dof-card>
            </dof-col>
            <dof-col>
              <dof-card>
                <div class="placeholder"></div>
              </dof-card>
            </dof-col>
          </dof-row>
          <dof-row class="m-b-10">
            <dof-col>
              <dof-card>
                <div class="placeholder"></div>
              </dof-card>
            </dof-col>
          </dof-row>
          <dof-row class="m-b-10">
            <dof-col>
              <dof-card>
                <div class="placeholder"></div>
              </dof-card>
            </dof-col>
            <dof-col>
              <dof-card>
                <div class="placeholder"></div>
              </dof-card>
            </dof-col>
          </dof-row>
          <dof-row class="m-b-10">
            <dof-col>
              <dof-card>
                <div class="placeholder"></div>
              </dof-card>
            </dof-col>
          </dof-row>
        </dof-board>
      </div>
      <div class="h-300px"></div>
      <dof-bottom-bar :tabGroups="tabTitles"></dof-bottom-bar>
    </scroller>
  </div>
</template>

<style scoped>
.wrapper {
  /* background-color: #f9f9f9; */
  position: relative;
}
.scroller {
  position: relative;
  flex: 1;
  /* background-color: #267aff; */
  /* background-image: linear-gradient(to top, #ffffff, #267aff); */
  width: 750px;
  height: 1500px;
  padding-bottom: 160px;
}

.backgroundTopColor {
  position: absolute;
  top: -1000px;
  width: 750px;
  height: 1000px;
}
.board-box {
  background-color: #f9f9f9;
}

.m-b-10 {
  margin-bottom: 20px;
}
.h-300px {
  width: 750px;
  height: 0;
  padding-bottom: 300px;
  background-color: #f9f9f9;
}
.placeholder {
  height: 160px;
}
</style>

<script>
import Title from 'src/_mods/title.vue'
import Category from 'src/_mods/catalog'
import {
  DofMinibar,
  DofGradient,
  DofBoard,
  DofRow,
  DofCol,
  DofCardGroup,
  DofCard,
  DofCardItem,
  DofBottomBar
} from 'dolphin-weex-ui'
const modal = weex.requireModule('modal')
import nativeService from '@/service/nativeService.js'

module.exports = {
  components: {
    Title,
    Category,
    DofMinibar,
    DofGradient,
    DofBoard,
    DofRow,
    DofCol,
    DofCardGroup,
    DofCard,
    DofCardItem,
    DofBottomBar
  },
  data() {
    return {
      leftButton: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/header/icon_back_white@3x.png',
      width: '750',
      height: '700',
      startColor: '',
      endColor: '#F9F9F9',
      tabTitles: [
        {
          type: 'power',
          title: 'power',
          text: '开关',
          iconColor: '#f2f2f2',
          disabled: false,
          icon: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/sample/water_heater/calorifier_icon_on@3x.png'
        }
      ]
    }
  },

  mounted() {
    let value = nativeService.getParameters('value') || '#267AFF'
    this.height = 600
    this.startColor = value
    this.tabTitles[0]['iconColor'] = value
  },
  methods: {
    back() {}
  },

  computed: {}
}
</script>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
Last Updated: 10/4/2022, 10:49:38 AM