background-image.uvue 985 字节
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>
W
wanganxp 已提交
6
			<text>不支持背景图片,仅支持linear-gradient方法</text>
shutao-dc's avatar
shutao-dc 已提交
7 8
				<view v-for="(direction) in directionData">
					<text>background-image: linear-gradient({{direction}}, red, yellow)</text>
9
				<view class="common" :style="{'background-image': backgroundSelect ?'linear-gradient('+direction+', red, yellow)':''}"></view>
shutao-dc's avatar
shutao-dc 已提交
10
      </view>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
11
		</view>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
12 13 14
  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
15 16 17
</template>

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

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