font-family.uvue 2.1 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
    <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>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
6 7
    <text class="common" style="font-family: AlimamaDaoLiTiOTF">font-family: 阿里妈妈刀隶体-otf</text>
    <text class="common" style="font-family: AlimamaDaoLiTiOTF;font-weight: bold;font-style: italic;">font-family: 阿里妈妈刀隶体-otf(粗斜体)</text>
8 9
    <text style="font-family: UniFontFamily;">style 加载非 static 目录字体文件:{{uniIcon}}</text>
    <!--    <text class="common" style="font-family: AlimamaDaoLiTiWOFF">font-family: 阿里妈妈刀隶体-woff</text>
10 11
    <text class="common" style="font-family: AlimamaDaoLiTiWOFF2">font-family: 阿里妈妈刀隶体-woff2</text> -->
  </view>
12
  <!-- #ifdef APP -->
13 14
  <view style="margin: 24px 12px;">
    <button type="default" @click="openUniIcon">内置字体图标uni-icon示例</button>
DCloud-WZF's avatar
DCloud-WZF 已提交
15
  </view>
16
  <!-- #endif -->
DCloud-WZF's avatar
DCloud-WZF 已提交
17 18
</template>

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

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

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

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

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

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