demo.vue 1.8 KB
Newer Older
richard_1015's avatar
richard_1015 已提交
1 2
<template>
  <div class="demo">
richard_1015's avatar
richard_1015 已提交
3 4
    <h2>基础用法</h2>
    <nut-cell>
richard_1015's avatar
richard_1015 已提交
5
      <nut-icon name="dongdong"></nut-icon>
richard_1015's avatar
richard_1015 已提交
6
      <nut-icon name="JD"></nut-icon>
richard_1015's avatar
richard_1015 已提交
7
    </nut-cell>
richard_1015's avatar
richard_1015 已提交
8 9 10 11 12 13 14
    <h2>图片链接</h2>
    <nut-cell>
      <nut-icon
        size="40px"
        name="https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png"
      ></nut-icon>
    </nut-cell>
richard_1015's avatar
richard_1015 已提交
15 16
    <h2>图标颜色</h2>
    <nut-cell>
richard_1015's avatar
richard_1015 已提交
17 18
      <nut-icon name="dongdong" color="#fa2c19"></nut-icon>
      <nut-icon name="dongdong" color="#64b578"></nut-icon>
richard_1015's avatar
richard_1015 已提交
19
      <nut-icon name="JD" color="#fa2c19"></nut-icon>
richard_1015's avatar
richard_1015 已提交
20 21 22 23
    </nut-cell>

    <h2>图标大小</h2>
    <nut-cell>
richard_1015's avatar
richard_1015 已提交
24 25 26
      <nut-icon name="dongdong"></nut-icon>
      <nut-icon name="dongdong" size="24px"></nut-icon>
      <nut-icon name="dongdong" size="16px"></nut-icon>
richard_1015's avatar
richard_1015 已提交
27 28 29 30 31 32 33 34 35 36 37
    </nut-cell>

    <h2>基础图标</h2>
    <nut-cell>
      <ul>
        <li v-for="item in icons.glyphs" :key="item.font_class">
          <nut-icon :name="item.font_class"></nut-icon>
          <span>{{ item.name }}</span>
        </li>
      </ul>
    </nut-cell>
richard_1015's avatar
richard_1015 已提交
38 39 40 41
  </div>
</template>

<script lang="ts">
richard_1015's avatar
richard_1015 已提交
42
import icons from '@/styles/font/iconfont.json';
richard_1015's avatar
richard_1015 已提交
43 44 45 46
import { createComponent } from '@/utils/create';
const { createDemo } = createComponent('icon');
export default createDemo({
  props: {},
richard_1015's avatar
richard_1015 已提交
47 48 49
  setup() {
    return { icons };
  }
richard_1015's avatar
richard_1015 已提交
50 51 52
});
</script>

richard_1015's avatar
richard_1015 已提交
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
<style lang="scss" scoped>
.nut-cell {
  > .nutui-iconfont {
    margin-right: 10px;
  }
}
ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  li {
    flex: 0 0 25%;
    max-width: 25%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    span {
      height: 40px;
    }
    .nutui-iconfont {
      margin: 16px 0 16px;
    }
  }
}
</style>