Blame view

examples/routers/avatar.vue 2.34 KB
2c5faf30   梁灏   init Avatar compo...
1
  <template>
a8afe010   梁灏   update Avatar demo
2
3
4
      <div class="demo-avatar">
          <Avatar :style="{background: color}">{{ user }}</Avatar>
          <Button size="small" @click="handleChange">Change</Button>
acf00f5c   梁灏   update Avatar style
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
          <div>
              <div class="demo-avatar">
                  <Avatar icon="ios-person" size="large" />
                  <Avatar icon="ios-person" />
                  <Avatar icon="ios-person" size="small" />
              </div>
              <div class="demo-avatar">
                  <Avatar shape="square" icon="ios-person" size="large" />
                  <Avatar shape="square" icon="ios-person" />
                  <Avatar shape="square" icon="ios-person" size="small" />
              </div>
          </div>
          <div class="demo-avatar">
              <Avatar icon="ios-person" />
              <Avatar>U</Avatar>
              <Avatar>USER</Avatar>
              <Avatar src="https://i.loli.net/2017/08/21/599a521472424.jpg" />
              <Avatar style="color: #f56a00;background-color: #fde3cf">U</Avatar>
              <Avatar style="background-color: #87d068" icon="ios-person" />
          </div>
          <div class="demo-avatar-badge">
              <Badge :count="1">
                  <Avatar shape="square" icon="ios-person" />
              </Badge>
              <Badge dot>
                  <Avatar shape="square" icon="ios-person" />
              </Badge>
          </div>
afafafce   梁灏   Avatar add custom...
33
34
          <br><br><br>
          <Avatar custom-icon="ivu-icon-ios-person" />
1d5d6ef6   梁灏   fixed #5136
35
36
  
          <Avatar :src="src" size="large" @on-error="handleError" />
a1530fac   梁灏   update Avatar
37
      </div>
2c5faf30   梁灏   init Avatar compo...
38
39
  </template>
  <script>
a8afe010   梁灏   update Avatar demo
40
41
42
      const UserList = ['二', '小二', '三', '二个人'];
      const ColorList = ['#f56a00', '#7265e6', '#ffbf00', '#00a2ae'];
  
2c5faf30   梁灏   init Avatar compo...
43
      export default {
ad225578   梁灏   add Avatar component
44
45
          data () {
              return {
a8afe010   梁灏   update Avatar demo
46
                  user: UserList[0],
1d5d6ef6   梁灏   fixed #5136
47
48
                  color: ColorList[0],
                  src: 'https://dev-file.iviewui.com/userinfoPDvn9gKWYihR24SpgC319vXY8qniCqj41/avatar'
ad225578   梁灏   add Avatar component
49
50
51
              }
          },
          methods: {
a8afe010   梁灏   update Avatar demo
52
53
54
55
              handleChange () {
                  const index = UserList.indexOf(this.user);
                  this.user = index < UserList.length - 1 ? UserList[index + 1] : UserList[0];
                  this.color = index < ColorList.length - 1 ? ColorList[index + 1] : ColorList[0];
1d5d6ef6   梁灏   fixed #5136
56
57
58
              },
              handleError () {
                  this.src = 'https://dev-file.iviewui.com/userinfoPDvn9gKWYihR24SpgC319vXY8qniCqj4/avatar';
ad225578   梁灏   add Avatar component
59
60
              }
          }
2c5faf30   梁灏   init Avatar compo...
61
62
      }
  </script>