Blame view

examples/routers/avatar.vue 828 Bytes
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>
a1530fac   梁灏   update Avatar
5
      </div>
2c5faf30   梁灏   init Avatar compo...
6
7
  </template>
  <script>
a8afe010   梁灏   update Avatar demo
8
9
10
      const UserList = ['二', '小二', '三', '二个人'];
      const ColorList = ['#f56a00', '#7265e6', '#ffbf00', '#00a2ae'];
  
2c5faf30   梁灏   init Avatar compo...
11
      export default {
ad225578   梁灏   add Avatar component
12
13
          data () {
              return {
a8afe010   梁灏   update Avatar demo
14
15
                  user: UserList[0],
                  color: ColorList[0]
ad225578   梁灏   add Avatar component
16
17
18
              }
          },
          methods: {
a8afe010   梁灏   update Avatar demo
19
20
21
22
              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];
ad225578   梁灏   add Avatar component
23
24
              }
          }
2c5faf30   梁灏   init Avatar compo...
25
26
      }
  </script>