font-family.uvue 1.9 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1
<template>
DCloud-WZF's avatar
DCloud-WZF 已提交
2
  <view class="uni-padding-wrap">
3 4 5 6
    <text class="common" style="font-family: monospace">font-family: monospace</text>
    <text class="common" style="font-family: cursive">font-family: cursive</text>
    <text class="common" style="font-family: AlimamaDaoLiTiTTF">font-family: 阿里妈妈刀隶体-ttf(网络字体下载后生效)</text>
    <text class="common" style="font-family: AlimamaDaoLiTiOTF">font-family: 阿里妈妈刀隶体-otf</text>
7 8
    <text style="font-family: UniFontFamily;">style 加载非 static 目录字体文件:{{uniIcon}}</text>
    <!--    <text class="common" style="font-family: AlimamaDaoLiTiWOFF">font-family: 阿里妈妈刀隶体-woff</text>
9 10
    <text class="common" style="font-family: AlimamaDaoLiTiWOFF2">font-family: 阿里妈妈刀隶体-woff2</text> -->
  </view>
11
  <!-- #ifdef APP -->
12 13
  <view style="margin: 24px 12px;">
    <button type="default" @click="openUniIcon">内置字体图标uni-icon示例</button>
DCloud-WZF's avatar
DCloud-WZF 已提交
14
  </view>
15
  <!-- #endif -->
DCloud-WZF's avatar
DCloud-WZF 已提交
16 17
</template>

18 19 20 21 22 23
<script lang="uts">
  export default {
    data() {
      return {
        uniIcon: '\ue100',
      }
24 25 26 27 28 29 30
    },
    methods: {
      openUniIcon() {
        uni.navigateTo({
          url: '/pages/CSS/text/font-family-icon'
        })
      }
31 32 33 34
    }
  }
</script>

DCloud-WZF's avatar
DCloud-WZF 已提交
35
<style>
36 37 38 39
  .common {
    font-size: 20px;
    line-height: 40px;
  }
40

41 42
  @font-face {
    font-family: AlimamaDaoLiTiTTF;
43
    src: url('https://qiniu-web-assets.dcloud.net.cn/uni-app-x/static/font/AlimamaDaoLiTi.ttf');
44
  }
45

46 47 48 49
  @font-face {
    font-family: AlimamaDaoLiTiOTF;
    src: url('/static/font/AlimamaDaoLiTi.otf');
  }
50 51 52 53 54 55 56

  @font-face {
    font-family: UniFontFamily;
    src: url('./uni.ttf');
  }

  /*  @font-face {
57 58 59 60 61 62 63
    font-family: AlimamaDaoLiTiWOFF;
    src: url('/static/font/AlimamaDaoLiTi.woff');
  }
  @font-face {
    font-family: AlimamaDaoLiTiWOFF2;
    src: url('/static/font/AlimamaDaoLiTi.woff2');
  } */
64
</style>