background-image.uvue 1.2 KB
Newer Older
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
1
<template>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
2 3 4
  <!-- #ifdef APP -->
  <scroll-view style="flex:1">
  <!-- #endif -->
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
5
		<view>
DCloud_iOS_XHY's avatar
DCloud_iOS_XHY 已提交
6
      <!-- 测试iOS平台宽高为0时,设置渐变色会不会导致闪退 -->
DCloud_iOS_XHY's avatar
DCloud_iOS_XHY 已提交
7
      <view style="width: 0px; height: 0px; background-image: linear-gradient(to bottom,#f5f5f5,#eff2f5);"></view>
W
wanganxp 已提交
8
			<text>不支持背景图片,仅支持linear-gradient方法</text>
shutao-dc's avatar
shutao-dc 已提交
9 10
				<view v-for="(direction) in directionData">
					<text>background-image: linear-gradient({{direction}}, red, yellow)</text>
11
				<view class="common" :style="{'background-image': backgroundSelect ?'linear-gradient('+direction+', red, yellow)':''}"></view>
shutao-dc's avatar
shutao-dc 已提交
12
      </view>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
13
		</view>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
14 15 16
  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
17 18 19
</template>

<script>
shutao-dc's avatar
shutao-dc 已提交
20 21 22
  export default {
    data(){
      return {
23
        backgroundSelect : true,
shutao-dc's avatar
shutao-dc 已提交
24 25
        directionData: ['to right', 'to left', 'to bottom', 'to top', 'to bottom left', 'to bottom right', 'to top left', 'to top right']
      }
26 27 28 29 30 31
    },
    methods: {
      //供自动化测试使用
      updateBackgroundSelect() {
        this.backgroundSelect = !this.backgroundSelect
      }
shutao-dc's avatar
shutao-dc 已提交
32 33
    }
  }
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
34 35 36 37
</script>

<style>
	.common {
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
38 39
		width: 250px;
		height: 250px;
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
40
	}
shutao-dc's avatar
shutao-dc 已提交
41
</style>